@@ -2548,7 +2548,7 @@ TEST_P(DBIteratorTest, AutoRefreshIterator) {
2548
2548
Options options = CurrentOptions ();
2549
2549
options.disable_auto_compactions = true ;
2550
2550
for (const bool auto_refresh_enabled : {false , true }) {
2551
- for (const bool use_snapshot : {false , true }) {
2551
+ for (const bool explicit_snapshot : {false , true }) {
2552
2552
DestroyAndReopen (options);
2553
2553
// Multi dimensional iterator:
2554
2554
//
@@ -2566,9 +2566,14 @@ TEST_P(DBIteratorTest, AutoRefreshIterator) {
2566
2566
}
2567
2567
2568
2568
ReadOptions read_options;
2569
- read_options.snapshot = use_snapshot ? db_->GetSnapshot () : nullptr ;
2569
+ std::unique_ptr<ManagedSnapshot> snapshot = nullptr ;
2570
+ if (explicit_snapshot) {
2571
+ snapshot = std::make_unique<ManagedSnapshot>(db_);
2572
+ }
2573
+ read_options.snapshot =
2574
+ explicit_snapshot ? snapshot->snapshot () : nullptr ;
2570
2575
read_options.auto_refresh_iterator_enabled = auto_refresh_enabled;
2571
- Iterator* iter = NewIterator (read_options);
2576
+ std::unique_ptr< Iterator> iter ( NewIterator (read_options) );
2572
2577
2573
2578
// This update should NOT be visible from the iterator.
2574
2579
ASSERT_OK (Put (Key (5 ), " new val" ));
@@ -2593,24 +2598,13 @@ TEST_P(DBIteratorTest, AutoRefreshIterator) {
2593
2598
for (iter->SeekToFirst (); iter->Valid (); iter->Next ()) {
2594
2599
ASSERT_OK (iter->status ());
2595
2600
it_num++;
2596
-
2597
2601
if (it_num == trigger_compact_on_it) {
2598
2602
// Bump the superversion by manually scheduling flush + compaction.
2599
2603
ASSERT_OK (Flush ());
2600
2604
ASSERT_OK (
2601
2605
dbfull ()->CompactRange (CompactRangeOptions (), nullptr , nullptr ));
2602
2606
ASSERT_OK (dbfull ()->TEST_WaitForBackgroundWork ());
2603
2607
2604
- // Flush and compaction background tasks are completed by now.
2605
- std::vector<LiveFileMetaData> new_files;
2606
- db_->GetLiveFilesMetaData (&new_files);
2607
-
2608
- // We expect a single, new SST file.
2609
- ASSERT_EQ (new_files.size (), 1 );
2610
- for (const auto & old_file : old_files) {
2611
- ASSERT_TRUE (old_file.file_number != new_files[0 ].file_number );
2612
- }
2613
-
2614
2608
// For accuracy, capture the memtables size right before consecutive
2615
2609
// iterator call to Next() will update its' stale superversion ref.
2616
2610
dbfull ()->GetIntProperty (" rocksdb.size-all-mem-tables" ,
@@ -2623,10 +2617,12 @@ TEST_P(DBIteratorTest, AutoRefreshIterator) {
2623
2617
ASSERT_OK (iter->GetProperty (" rocksdb.iterator.super-version-number" ,
2624
2618
&prop_value));
2625
2619
uint64_t new_superversion_number = std::stoi (prop_value);
2620
+ Status expected_status_for_preexisting_files;
2626
2621
if (!auto_refresh_enabled) {
2627
2622
ASSERT_EQ (superversion_number, new_superversion_number);
2628
2623
ASSERT_EQ (all_memtables_size_after_refresh,
2629
2624
all_memtables_size_before_refresh);
2625
+ expected_status_for_preexisting_files = Status::OK ();
2630
2626
} else {
2631
2627
// Iterator is expected to detect its' superversion staleness.
2632
2628
ASSERT_LT (superversion_number, new_superversion_number);
@@ -2635,6 +2631,12 @@ TEST_P(DBIteratorTest, AutoRefreshIterator) {
2635
2631
// upon automatical iterator refresh.
2636
2632
ASSERT_GT (all_memtables_size_before_refresh,
2637
2633
all_memtables_size_after_refresh);
2634
+ expected_status_for_preexisting_files = Status::NotFound ();
2635
+ }
2636
+
2637
+ for (const auto & file : old_files) {
2638
+ ASSERT_EQ (env_->FileExists (file.db_path + " /" + file.name ),
2639
+ expected_status_for_preexisting_files);
2638
2640
}
2639
2641
}
2640
2642
@@ -2653,11 +2655,6 @@ TEST_P(DBIteratorTest, AutoRefreshIterator) {
2653
2655
}
2654
2656
ASSERT_EQ (kv->second , " val" + std::to_string (val));
2655
2657
}
2656
-
2657
- delete iter;
2658
- if (use_snapshot) {
2659
- db_->ReleaseSnapshot (read_options.snapshot );
2660
- }
2661
2658
}
2662
2659
}
2663
2660
}
0 commit comments