@@ -128,7 +128,8 @@ class NonBatchedOpsStressTest : public StressTest {
128
128
s = Status::NotFound ();
129
129
}
130
130
131
- VerifyOrSyncValue (static_cast <int >(cf), i, options, shared, from_db,
131
+ VerifyOrSyncValue (static_cast <int >(cf), i, options, shared,
132
+ shared->Get (cf, i), from_db,
132
133
/* msg_prefix */ " Iterator verification" , s);
133
134
134
135
if (!from_db.empty ()) {
@@ -147,7 +148,8 @@ class NonBatchedOpsStressTest : public StressTest {
147
148
148
149
Status s = db_->Get (options, column_families_[cf], key, &from_db);
149
150
150
- VerifyOrSyncValue (static_cast <int >(cf), i, options, shared, from_db,
151
+ VerifyOrSyncValue (static_cast <int >(cf), i, options, shared,
152
+ shared->Get (cf, i), from_db,
151
153
/* msg_prefix */ " Get verification" , s);
152
154
153
155
if (!from_db.empty ()) {
@@ -182,7 +184,8 @@ class NonBatchedOpsStressTest : public StressTest {
182
184
}
183
185
}
184
186
185
- VerifyOrSyncValue (static_cast <int >(cf), i, options, shared, from_db,
187
+ VerifyOrSyncValue (static_cast <int >(cf), i, options, shared,
188
+ shared->Get (cf, i), from_db,
186
189
/* msg_prefix */ " GetEntity verification" , s);
187
190
188
191
if (!from_db.empty ()) {
@@ -217,7 +220,8 @@ class NonBatchedOpsStressTest : public StressTest {
217
220
const std::string from_db = values[j].ToString ();
218
221
219
222
VerifyOrSyncValue (static_cast <int >(cf), i + j, options, shared,
220
- from_db, /* msg_prefix */ " MultiGet verification" ,
223
+ shared->Get (cf, i + j), from_db,
224
+ /* msg_prefix */ " MultiGet verification" ,
221
225
statuses[j]);
222
226
223
227
if (!from_db.empty ()) {
@@ -268,9 +272,10 @@ class NonBatchedOpsStressTest : public StressTest {
268
272
}
269
273
}
270
274
271
- VerifyOrSyncValue (
272
- static_cast <int >(cf), i + j, options, shared, from_db,
273
- /* msg_prefix */ " MultiGetEntity verification" , statuses[j]);
275
+ VerifyOrSyncValue (static_cast <int >(cf), i + j, options, shared,
276
+ shared->Get (cf, i + j), from_db,
277
+ /* msg_prefix */ " MultiGetEntity verification" ,
278
+ statuses[j]);
274
279
275
280
if (!from_db.empty ()) {
276
281
PrintKeyValue (static_cast <int >(cf), static_cast <uint32_t >(i + j),
@@ -321,7 +326,8 @@ class NonBatchedOpsStressTest : public StressTest {
321
326
from_db = values[number_of_operands - 1 ].ToString ();
322
327
}
323
328
324
- VerifyOrSyncValue (static_cast <int >(cf), i, options, shared, from_db,
329
+ VerifyOrSyncValue (static_cast <int >(cf), i, options, shared,
330
+ shared->Get (cf, i), from_db,
325
331
/* msg_prefix */ " GetMergeOperands verification" ,
326
332
s);
327
333
@@ -339,24 +345,52 @@ class NonBatchedOpsStressTest : public StressTest {
339
345
return ;
340
346
}
341
347
348
+ assert (cmp_db_);
349
+ assert (!cmp_cfhs_.empty ());
350
+ Status s = cmp_db_->TryCatchUpWithPrimary ();
351
+ if (!s.ok ()) {
352
+ assert (false );
353
+ exit (1 );
354
+ }
355
+
356
+ auto * shared = thread->shared ;
357
+ assert (shared);
358
+ const int64_t max_key = shared->GetMaxKey ();
359
+ ReadOptions read_opts (FLAGS_verify_checksum, true );
360
+
342
361
if (thread->shared ->HasHistory ()) {
343
- std::unique_ptr<ExpectedState> state ;
344
- Status getExpectedStateStatus =
345
- thread->shared ->GetExpectedState (db_, state );
346
- if (!getExpectedStateStatus .ok ()) {
362
+ uint64_t start_get_expected_state = clock_-> NowMicros () ;
363
+ Status setSecondaryExpectedStateStatus =
364
+ thread->shared ->SetSecondaryExpectedState (cmp_db_ );
365
+ if (!setSecondaryExpectedStateStatus .ok ()) {
347
366
std::cout << " [NonBatchedOpsStressTest::ContinuouslyVerifyDb]: Failed "
348
367
" to get expected state"
349
368
<< std::endl;
350
369
assert (false );
351
370
}
352
- }
371
+ uint64_t end_get_expected_state = clock_->NowMicros ();
372
+ std::cout << " Retrieved expected state in "
373
+ << end_get_expected_state - start_get_expected_state
374
+ << " microseconds" << std::endl;
353
375
354
- assert (cmp_db_);
355
- assert (!cmp_cfhs_.empty ());
356
- Status s = cmp_db_->TryCatchUpWithPrimary ();
357
- if (!s.ok ()) {
358
- assert (false );
359
- exit (1 );
376
+ uint64_t start_secondary_scan = clock_->NowMicros ();
377
+ for (int64_t i = 0 ; i < max_key; ++i) {
378
+ if (thread->shared ->HasVerificationFailedYet ()) {
379
+ break ;
380
+ }
381
+ const std::string key = Key (i);
382
+ std::string from_db;
383
+ s = cmp_db_->Get (read_opts, column_families_[0 ], key, &from_db);
384
+ if (!VerifyOrSyncValue (
385
+ 0 , i, read_opts, shared, shared->GetSecondary (0 , i), from_db,
386
+ /* msg_prefix */ " Secondary get verification" , s)) {
387
+ std::cout << " Failed on key i=" << i << std::endl;
388
+ }
389
+ }
390
+ uint64_t end_secondary_scan = clock_->NowMicros ();
391
+ std::cout << " Scanned all of secondary db in "
392
+ << end_secondary_scan - start_secondary_scan << " microseconds"
393
+ << std::endl;
360
394
}
361
395
362
396
const auto checksum_column_family = [](Iterator* iter,
@@ -371,10 +405,6 @@ class NonBatchedOpsStressTest : public StressTest {
371
405
return iter->status ();
372
406
};
373
407
374
- auto * shared = thread->shared ;
375
- assert (shared);
376
- const int64_t max_key = shared->GetMaxKey ();
377
- ReadOptions read_opts (FLAGS_verify_checksum, true );
378
408
std::string ts_str;
379
409
Slice ts;
380
410
if (FLAGS_user_timestamp_size > 0 ) {
@@ -1644,9 +1674,11 @@ class NonBatchedOpsStressTest : public StressTest {
1644
1674
1645
1675
std::string from_db;
1646
1676
Status s = db_->Get (read_opts, cfh, k, &from_db);
1647
- bool res = VerifyOrSyncValue (
1648
- rand_column_family, rand_key, read_opts, shared,
1649
- /* msg_prefix */ " Pre-Put Get verification" , from_db, s);
1677
+ // looks like these arguments for msg_prefix and from_db were swapped
1678
+ bool res =
1679
+ VerifyOrSyncValue (rand_column_family, rand_key, read_opts, shared,
1680
+ shared->Get (rand_column_family, rand_key), from_db,
1681
+ /* msg_prefix */ " Pre-Put Get verification" , s);
1650
1682
1651
1683
// Enable back error injection disabled for preparation
1652
1684
if (fault_fs_guard) {
@@ -2729,21 +2761,13 @@ class NonBatchedOpsStressTest : public StressTest {
2729
2761
}
2730
2762
2731
2763
bool VerifyOrSyncValue (int cf, int64_t key, const ReadOptions& opts,
2732
- SharedState* shared, const std::string& value_from_db,
2764
+ SharedState* shared,
2765
+ const ExpectedValue& expected_value,
2766
+ const std::string& value_from_db,
2733
2767
std::string msg_prefix, const Status& s) const {
2734
2768
if (shared->HasVerificationFailedYet ()) {
2735
2769
return false ;
2736
2770
}
2737
- if (shared->HasHistory ()) {
2738
- std::unique_ptr<ExpectedState> state;
2739
- Status getExpectedStateStatus = shared->GetExpectedState (db_, state);
2740
- if (!getExpectedStateStatus.ok ()) {
2741
- std::cout << " [VerifyOrSyncValue]: Failed to get expected state"
2742
- << std::endl;
2743
- return false ;
2744
- }
2745
- }
2746
- const ExpectedValue expected_value = shared->Get (cf, key);
2747
2771
2748
2772
if (expected_value.PendingWrite () || expected_value.PendingDelete ()) {
2749
2773
if (s.ok ()) {
0 commit comments