@@ -339,10 +339,26 @@ class NonBatchedOpsStressTest : public StressTest {
339
339
}
340
340
assert (cmp_db_);
341
341
assert (!cmp_cfhs_.empty ());
342
+
342
343
auto * shared = thread->shared ;
343
344
assert (shared);
345
+
346
+ const int64_t max_key = shared->GetMaxKey ();
347
+ const int64_t keys_per_thread = max_key / shared->GetNumThreads ();
348
+ int64_t start = keys_per_thread * thread->tid ;
349
+ int64_t end = thread->tid == shared->GetNumThreads () - 1
350
+ ? max_key
351
+ : start + keys_per_thread;
352
+
353
+ // We are going to read in the expected values before catching up to the
354
+ // primary to determine the lower bound of the acceptable values that can be
355
+ // returned from the secondary. After each Get() to the secondary, we are
356
+ // going to read in the expected value again to determine the upper bound.
357
+ // As long as the returned value from Get() is within these bounds, we
358
+ // consider that okay. The lower bound will always be moving forwards
359
+ // anyways as TryCatchUpWithPrimary() gets called.
344
360
std::vector<ExpectedValue> pre_read_expected_values;
345
- for (int64_t i = 0 ; i < 1000 ; ++i) {
361
+ for (int64_t i = start ; i < end ; ++i) {
346
362
pre_read_expected_values.push_back (shared->Get (0 , i));
347
363
}
348
364
@@ -354,10 +370,14 @@ class NonBatchedOpsStressTest : public StressTest {
354
370
355
371
ReadOptions read_opts (FLAGS_verify_checksum, true );
356
372
357
- for (int64_t i = 0 ; i < 1000 ; ++i) {
358
- const ExpectedValue pre_read_expected_value = pre_read_expected_values[i];
373
+ for (int64_t i = start; i < end; ++i) {
374
+ if (shared->HasVerificationFailedYet ()) {
375
+ break ;
376
+ }
377
+ const ExpectedValue pre_read_expected_value =
378
+ pre_read_expected_values[i - start];
359
379
std::string from_db;
360
- std::string key_str = Key (rand_keys[ 0 ] );
380
+ std::string key_str = Key (i );
361
381
Slice key = key_str;
362
382
s = db_->Get (read_opts, column_families_[0 ], key_str, &from_db);
363
383
const ExpectedValue post_read_expected_value = shared->Get (0 , i);
@@ -369,7 +389,7 @@ class NonBatchedOpsStressTest : public StressTest {
369
389
post_read_expected_value)) {
370
390
std::cout << " Secondary verification failed for i=" << i
371
391
<< " , key=" << key.ToString (true )
372
- << " . The value_base from the db was " << value_base_from_db
392
+ << " . Get() returned a value base " << value_base_from_db
373
393
<< " which was outside of the value base range of"
374
394
<< pre_read_expected_value.GetValueBase () << " to"
375
395
<< post_read_expected_value.GetFinalValueBase ()
@@ -403,7 +423,6 @@ class NonBatchedOpsStressTest : public StressTest {
403
423
return iter->status ();
404
424
};
405
425
406
- const int64_t max_key = shared->GetMaxKey ();
407
426
std::string ts_str;
408
427
Slice ts;
409
428
if (FLAGS_user_timestamp_size > 0 ) {
@@ -414,17 +433,6 @@ class NonBatchedOpsStressTest : public StressTest {
414
433
415
434
static Random64 rand64 (shared->GetSeed ());
416
435
417
- {
418
- uint32_t crc = 0 ;
419
- std::unique_ptr<Iterator> it (cmp_db_->NewIterator (read_opts));
420
- s = checksum_column_family (it.get (), &crc);
421
- if (!s.ok ()) {
422
- fprintf (stderr, " Computing checksum of default cf: %s\n " ,
423
- s.ToString ().c_str ());
424
- assert (false );
425
- }
426
- }
427
-
428
436
for (auto * handle : cmp_cfhs_) {
429
437
if (thread->rand .OneInOpt (3 )) {
430
438
// Use Get()
@@ -435,7 +443,10 @@ class NonBatchedOpsStressTest : public StressTest {
435
443
s = cmp_db_->Get (read_opts, handle, key_str, &value,
436
444
FLAGS_user_timestamp_size > 0 ? &key_ts : nullptr );
437
445
s.PermitUncheckedError ();
438
- } else {
446
+ } else if (!FLAGS_inplace_update_support) {
447
+ // The combination of inplace_update_support=true and backward iteration
448
+ // is not allowed
449
+
439
450
// Use range scan
440
451
std::unique_ptr<Iterator> iter (cmp_db_->NewIterator (read_opts, handle));
441
452
uint32_t rnd = (thread->rand .Next ()) % 4 ;
@@ -458,6 +469,7 @@ class NonBatchedOpsStressTest : public StressTest {
458
469
iter->Seek (key_str);
459
470
for (int i = 0 ; i < 5 && iter->Valid (); ++i, iter->Next ()) {
460
471
}
472
+
461
473
} else {
462
474
// SeekForPrev() + Prev()*5
463
475
uint64_t key = rand64.Uniform (static_cast <uint64_t >(max_key));
@@ -466,6 +478,15 @@ class NonBatchedOpsStressTest : public StressTest {
466
478
for (int i = 0 ; i < 5 && iter->Valid (); ++i, iter->Prev ()) {
467
479
}
468
480
}
481
+ } else {
482
+ uint32_t crc = 0 ;
483
+ std::unique_ptr<Iterator> it (cmp_db_->NewIterator (read_opts, handle));
484
+ s = checksum_column_family (it.get (), &crc);
485
+ if (!s.ok ()) {
486
+ fprintf (stderr, " Computing checksum of default cf: %s\n " ,
487
+ s.ToString ().c_str ());
488
+ assert (false );
489
+ }
469
490
}
470
491
}
471
492
}
0 commit comments