@@ -53,11 +53,11 @@ func TestExportCmd(t *testing.T) {
53
53
dir , dirCleanupFn := testutils .TempDir (t )
54
54
defer dirCleanupFn ()
55
55
srv , db , kvDB := serverutils .StartServer (t , base.TestServerArgs {
56
- DefaultTestTenant : base .TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet (109429 ),
57
- ExternalIODir : dir ,
56
+ ExternalIODir : dir ,
58
57
})
59
58
defer srv .Stopper ().Stop (ctx )
60
59
ts := srv .ApplicationLayer ()
60
+ ss := srv .SystemLayer ()
61
61
62
62
export := func (
63
63
t * testing.T , start hlc.Timestamp , mvccFilter kvpb.MVCCFilter , maxResponseSSTBytes int64 ,
@@ -184,28 +184,22 @@ func TestExportCmd(t *testing.T) {
184
184
t , sqlDB .DB , "mvcclatest" , "public" , "export" ,
185
185
))
186
186
187
- const (
188
- targetSizeSetting = "kv.bulk_sst.target_size"
189
- maxOverageSetting = "kv.bulk_sst.max_allowed_overage"
190
- )
191
187
var (
192
- setSetting = func (t * testing.T , variable , val string ) {
193
- sqlDB .Exec (t , "SET CLUSTER SETTING " + variable + " = " + val )
194
- }
195
- resetSetting = func (t * testing.T , variable string ) {
196
- setSetting (t , variable , "DEFAULT" )
197
- }
198
- setExportTargetSize = func (t * testing.T , val string ) {
199
- setSetting (t , targetSizeSetting , val )
188
+ setExportTargetSize = func (t * testing.T , val int64 ) {
189
+ batcheval .ExportRequestTargetFileSize .Override (ctx , & ss .ClusterSettings ().SV , val )
200
190
}
201
191
resetExportTargetSize = func (t * testing.T ) {
202
- resetSetting (t , targetSizeSetting )
192
+ batcheval .ExportRequestTargetFileSize .Override (
193
+ ctx , & ss .ClusterSettings ().SV , batcheval .ExportRequestTargetFileSize .Default (),
194
+ )
203
195
}
204
- setMaxOverage = func (t * testing.T , val string ) {
205
- setSetting ( t , maxOverageSetting , val )
196
+ setMaxOverage = func (t * testing.T , val int64 ) {
197
+ batcheval . ExportRequestMaxAllowedFileSizeOverage . Override ( ctx , & ss . ClusterSettings (). SV , val )
206
198
}
207
199
resetMaxOverage = func (t * testing.T ) {
208
- resetSetting (t , maxOverageSetting )
200
+ batcheval .ExportRequestMaxAllowedFileSizeOverage .Override (
201
+ ctx , & ss .ClusterSettings ().SV , batcheval .ExportRequestMaxAllowedFileSizeOverage .Default (),
202
+ )
209
203
}
210
204
)
211
205
@@ -220,7 +214,7 @@ func TestExportCmd(t *testing.T) {
220
214
res1 = exportAndSlurp (t , hlc.Timestamp {}, noTargetBytes )
221
215
expect (t , res1 , 1 , 2 , 1 , 4 )
222
216
defer resetExportTargetSize (t )
223
- setExportTargetSize (t , "'1b'" )
217
+ setExportTargetSize (t , 1 )
224
218
res1 = exportAndSlurp (t , hlc.Timestamp {}, noTargetBytes )
225
219
expect (t , res1 , 2 , 2 , 3 , 4 )
226
220
})
@@ -264,7 +258,7 @@ func TestExportCmd(t *testing.T) {
264
258
265
259
// Re-run the test with a 1b target size which will lead to more files.
266
260
defer resetExportTargetSize (t )
267
- setExportTargetSize (t , "'1b'" )
261
+ setExportTargetSize (t , 1 )
268
262
res5 = exportAndSlurp (t , hlc.Timestamp {}, noTargetBytes )
269
263
expect (t , res5 , 2 , 2 , 4 , 7 )
270
264
})
@@ -287,15 +281,17 @@ INTO
287
281
288
282
// Re-run the test with a 1b target size which will lead to 100 files.
289
283
defer resetExportTargetSize (t )
290
- setExportTargetSize (t , "'1b'" )
284
+ setExportTargetSize (t , 1 )
291
285
res6 = exportAndSlurp (t , res5 .end , noTargetBytes )
292
286
expect (t , res6 , 100 , 100 , 100 , 100 )
293
287
294
288
// Set the MaxOverage to 1b and ensure that we get errors due to
295
289
// the max overage being exceeded.
296
290
defer resetMaxOverage (t )
297
- setMaxOverage (t , "'1b'" )
298
- const expectedError = `export size \(11 bytes\) exceeds max size \(2 bytes\)`
291
+ setMaxOverage (t , 1 )
292
+ // NB: Depending on which version of the test we're running (system tenant
293
+ // vs. secondary), we'll get a different size for the export request.
294
+ const expectedError = `export size \((11|13) bytes\) exceeds max size \(2 bytes\)`
299
295
_ , pErr := export (t , res5 .end , kvpb .MVCCFilter_Latest , noTargetBytes )
300
296
require .Regexp (t , expectedError , pErr )
301
297
hints := errors .GetAllHints (pErr .GoError ())
307
303
308
304
// Disable the TargetSize and ensure that we don't get any errors
309
305
// to the max overage being exceeded.
310
- setExportTargetSize (t , "'0b'" )
306
+ setExportTargetSize (t , 0 )
311
307
res6 = exportAndSlurp (t , res5 .end , noTargetBytes )
312
308
expect (t , res6 , 2 , 100 , 2 , 100 )
313
309
})
@@ -316,6 +312,11 @@ INTO
316
312
t .Run ("ts7" , func (t * testing.T ) {
317
313
var maxResponseSSTBytes int64
318
314
kvByteSize := int64 (11 )
315
+ if ! ts .Codec ().IsSystem () {
316
+ // The kv byte size is different between the system tenant and secondary
317
+ // tenants because of the extra tenant prefix.
318
+ kvByteSize = 13
319
+ }
319
320
// Because of the above split, there are going to be two ExportRequests by
320
321
// the DistSender. One for the first KV and the next one for the remaining
321
322
// KVs.
@@ -337,6 +338,12 @@ INTO
337
338
}
338
339
expectResponseHeader (t , res7 , latestRespHeader , allRespHeader )
339
340
341
+ var optTenantPrefix string
342
+ endKey := "/Max"
343
+ if ! srv .Codec ().IsSystem () {
344
+ optTenantPrefix = srv .Codec ().TenantPrefix ().String ()
345
+ endKey = srv .Codec ().TenantPrefix ().PrefixEnd ().String ()
346
+ }
340
347
// No TargetSize and TargetBytes is equal to the size of a single KV. The
341
348
// first ExportRequest will reduce the limit for the second request to zero
342
349
// and so we should only see a single ExportRequest and an accurate
@@ -346,16 +353,16 @@ INTO
346
353
expect (t , res7 , 1 , 1 , 1 , 1 )
347
354
latestRespHeader = kvpb.ResponseHeader {
348
355
ResumeSpan : & roachpb.Span {
349
- Key : []byte (fmt .Sprintf ("/Table/%d/1/2" , tableID )),
350
- EndKey : []byte ("/Max" ),
356
+ Key : []byte (fmt .Sprintf ("%s /Table/%d/1/2" , optTenantPrefix , tableID )),
357
+ EndKey : []byte (endKey ),
351
358
},
352
359
ResumeReason : kvpb .RESUME_BYTE_LIMIT ,
353
360
NumBytes : maxResponseSSTBytes ,
354
361
}
355
362
allRespHeader = kvpb.ResponseHeader {
356
363
ResumeSpan : & roachpb.Span {
357
- Key : []byte (fmt .Sprintf ("/Table/%d/1/2" , tableID )),
358
- EndKey : []byte ("/Max" ),
364
+ Key : []byte (fmt .Sprintf ("%s /Table/%d/1/2" , optTenantPrefix , tableID )),
365
+ EndKey : []byte (endKey ),
359
366
},
360
367
ResumeReason : kvpb .RESUME_BYTE_LIMIT ,
361
368
NumBytes : maxResponseSSTBytes ,
@@ -364,45 +371,45 @@ INTO
364
371
365
372
// TargetSize to one KV and TargetBytes to two KVs. We should see one KV in
366
373
// each ExportRequest SST.
367
- setExportTargetSize (t , "'11b'" )
374
+ setExportTargetSize (t , 11 )
368
375
maxResponseSSTBytes = 2 * kvByteSize
369
376
res7 = exportAndSlurp (t , res5 .end , maxResponseSSTBytes )
370
377
expect (t , res7 , 2 , 2 , 2 , 2 )
371
378
latestRespHeader = kvpb.ResponseHeader {
372
379
ResumeSpan : & roachpb.Span {
373
- Key : []byte (fmt .Sprintf ("/Table/%d/1/3/0" , tableID )),
374
- EndKey : []byte ("/Max" ),
380
+ Key : []byte (fmt .Sprintf ("%s /Table/%d/1/3/0" , optTenantPrefix , tableID )),
381
+ EndKey : []byte (endKey ),
375
382
},
376
383
ResumeReason : kvpb .RESUME_BYTE_LIMIT ,
377
384
NumBytes : maxResponseSSTBytes ,
378
385
}
379
386
allRespHeader = kvpb.ResponseHeader {
380
387
ResumeSpan : & roachpb.Span {
381
- Key : []byte (fmt .Sprintf ("/Table/%d/1/3/0" , tableID )),
382
- EndKey : []byte ("/Max" ),
388
+ Key : []byte (fmt .Sprintf ("%s /Table/%d/1/3/0" , optTenantPrefix , tableID )),
389
+ EndKey : []byte (endKey ),
383
390
},
384
391
ResumeReason : kvpb .RESUME_BYTE_LIMIT ,
385
392
NumBytes : maxResponseSSTBytes ,
386
393
}
387
394
expectResponseHeader (t , res7 , latestRespHeader , allRespHeader )
388
395
389
396
// TargetSize to one KV and TargetBytes to one less than the total KVs.
390
- setExportTargetSize (t , "'11b'" )
397
+ setExportTargetSize (t , 11 )
391
398
maxResponseSSTBytes = 99 * kvByteSize
392
399
res7 = exportAndSlurp (t , res5 .end , maxResponseSSTBytes )
393
400
expect (t , res7 , 99 , 99 , 99 , 99 )
394
401
latestRespHeader = kvpb.ResponseHeader {
395
402
ResumeSpan : & roachpb.Span {
396
- Key : []byte (fmt .Sprintf ("/Table/%d/1/100/0" , tableID )),
397
- EndKey : []byte ("/Max" ),
403
+ Key : []byte (fmt .Sprintf ("%s /Table/%d/1/100/0" , optTenantPrefix , tableID )),
404
+ EndKey : []byte (endKey ),
398
405
},
399
406
ResumeReason : kvpb .RESUME_BYTE_LIMIT ,
400
407
NumBytes : maxResponseSSTBytes ,
401
408
}
402
409
allRespHeader = kvpb.ResponseHeader {
403
410
ResumeSpan : & roachpb.Span {
404
- Key : []byte (fmt .Sprintf ("/Table/%d/1/100/0" , tableID )),
405
- EndKey : []byte ("/Max" ),
411
+ Key : []byte (fmt .Sprintf ("%s /Table/%d/1/100/0" , optTenantPrefix , tableID )),
412
+ EndKey : []byte (endKey ),
406
413
},
407
414
ResumeReason : kvpb .RESUME_BYTE_LIMIT ,
408
415
NumBytes : maxResponseSSTBytes ,
412
419
// Target Size to one KV and TargetBytes to greater than all KVs. Checks if
413
420
// final NumBytes is accurate.
414
421
defer resetExportTargetSize (t )
415
- setExportTargetSize (t , "'11b'" )
422
+ setExportTargetSize (t , 11 )
416
423
maxResponseSSTBytes = 101 * kvByteSize
417
424
res7 = exportAndSlurp (t , res5 .end , maxResponseSSTBytes )
418
425
expect (t , res7 , 100 , 100 , 100 , 100 )
0 commit comments