From 8b430e01dc91ec95194df71a794dfd3088afdfe6 Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Mon, 3 Oct 2022 16:22:39 -0700 Subject: [PATCH] Add iterator refresh to stress test (#10766) Summary: added calls to `Iterator::Refresh()` in `NonBatchedOpsStressTest::TestIterateAgainstExpected()`. The testing key range is locked in `TestIterateAgainstExpected` so I do not expect this change to provide thorough stress test to `Iterator::Refresh()`. However, it can still be helpful for catching bugs like https://github.com/facebook/rocksdb/issues/10739. Will add calls to refresh in `TestIterate` once we support iterator refresh with snapshots. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10766 Test Plan: `python3 tools/db_crashtest.py whitebox --simple --verify_iterator_with_expected_state_one_in=2` Reviewed By: ajkr Differential Revision: D40008320 Pulled By: ajkr fbshipit-source-id: cec93b07f915ef6476d41c1fee9b23c115188085 --- db_stress_tool/no_batched_ops_stress.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db_stress_tool/no_batched_ops_stress.cc b/db_stress_tool/no_batched_ops_stress.cc index b809902dc..79c868f16 100644 --- a/db_stress_tool/no_batched_ops_stress.cc +++ b/db_stress_tool/no_batched_ops_stress.cc @@ -1224,6 +1224,11 @@ class NonBatchedOpsStressTest : public StressTest { op_logs += "P"; } + if (thread->rand.OneIn(2)) { + // Refresh after forward/backward scan to allow higher chance of SV + // change. It is safe to refresh since the testing key range is locked. + iter->Refresh(); + } // start from middle of [lb, ub) otherwise it is easy to iterate out of // locked range int64_t mid = lb + static_cast(FLAGS_num_iterations / 2);