@@ -421,7 +421,7 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
421421 this ->m_shadow_map .save (m_shadow_filename);
422422 }
423423
424- void reapply_after_crash (OperationList& operations) {
424+ void reapply_after_crash (OperationList& operations, std::optional< std::pair< uint32_t , uint32_t > > range_remove_keys ) {
425425 for (const auto & [key, opType] : operations) {
426426 switch (opType) {
427427 case OperationType::Put:
@@ -434,6 +434,11 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
434434 break ;
435435 }
436436 }
437+ if (range_remove_keys) {
438+ auto [s_key, e_key] = *range_remove_keys;
439+ LOGDEBUG (" Reapply: Range removing keys [{}, {})" , s_key, e_key);
440+ this ->range_remove_all (s_key, e_key);
441+ }
437442 trigger_cp (true );
438443 }
439444
@@ -494,7 +499,7 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
494499 LOGINFO (" Sanity check passed for {} keys!" , count);
495500 }
496501
497- void crash_and_recover_common (OperationList& operations, std::string filename = " " ) {
502+ void crash_and_recover_common (OperationList& operations, std::string filename = " " , std::optional< std::pair< uint32_t , uint32_t > > range_remove_keys = std:: nullopt ) {
498503 print_keys_logging (" Btree prior to CP and susbsequent simulated crash: " );
499504 LOGINFO (" Before Crash: {} keys in shadow map and it is actually {} keys in tree - operations size {}" ,
500505 this ->m_shadow_map .size (), tree_key_count (), operations.size ());
@@ -521,7 +526,7 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
521526 // test_common::HSTestHelper::trigger_cp(true);
522527 LOGINFO (" Before Reapply: {} keys in shadow map and actually {} in trees operation size {}" ,
523528 this ->m_shadow_map .size (), tree_key_count (), operations.size ());
524- this ->reapply_after_crash (operations);
529+ this ->reapply_after_crash (operations, range_remove_keys );
525530 if (!filename.empty ()) {
526531 std::string re_filename = filename + " _after_reapply.dot" ;
527532 LOGINFO (" Visualize the tree after reapply {}" , re_filename);
@@ -541,11 +546,11 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
541546 this ->crash_and_recover_common (operations, filename);
542547 }
543548
544- void crash_and_recover (std::vector< std::string >& flips, OperationList& operations, std::string filename = " " ) {
549+ void crash_and_recover (std::vector< std::string >& flips, OperationList& operations, std::string filename = " " , std::optional< std::pair< uint32_t , uint32_t > > range_remove_keys = std:: nullopt ) {
545550 for (auto const & flip : flips) {
546551 this ->remove_flip (flip);
547552 }
548- this ->crash_and_recover_common (operations, filename);
553+ this ->crash_and_recover_common (operations, filename, range_remove_keys );
549554 }
550555
551556 uint32_t tree_key_count () { return this ->m_bt ->count_keys (this ->m_bt ->root_node_id ()); }
@@ -731,11 +736,12 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
731736 }
732737 }
733738 }
739+ std::optional< std::pair< uint32_t , uint32_t > > range_remove_keys = std::nullopt ;
734740 if (crash_test_options.range_remove_ ) {
735741 // add one range remove operation
736- auto op = this ->range_remove_op (generator, crash_test_options.num_entries_per_rounds );
737- LOGDEBUG (" Range removing keys [{}, {})" , op. first , op. second );
738- this ->range_remove_all (op. first , op. second );
742+ range_remove_keys = this ->range_remove_op (generator, crash_test_options.num_entries_per_rounds );
743+ LOGDEBUG (" Range removing keys [{}, {})" , range_remove_keys-> first , range_remove_keys-> second );
744+ this ->range_remove_all (range_remove_keys-> first , range_remove_keys-> second );
739745 }
740746 if (normal_execution) {
741747 if (clean_shutdown) {
@@ -746,8 +752,7 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
746752 this ->get_all ();
747753 }
748754 } else {
749- // remove the flips so that they do not get triggered erroneously
750- this ->crash_and_recover (flips, operations, fmt::format (" long_tree_{}" , round));
755+ this ->crash_and_recover (flips, operations, fmt::format (" long_tree_{}" , round), range_remove_keys);
751756 }
752757 if (elapsed_time - last_progress_time > 30 ) {
753758 last_progress_time = elapsed_time;
0 commit comments