diff --git a/HISTORY.md b/HISTORY.md index 18feefafc..825c1def4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -29,6 +29,7 @@ * Fix a bug in WAL replay of secondary instance by skipping write batches with older sequence numbers than the current last sequence number. * Fix flush's/compaction's merge processing logic which allowed `Put`s covered by range tombstones to reappear. Note `Put`s may exist even if the user only ever called `Merge()` due to an internal conversion during compaction to the bottommost level. * Fix/improve memtable earliest sequence assignment and WAL replay so that WAL entries of unflushed column families will not be skipped after replaying the MANIFEST and increasing db sequence due to another flushed/compacted column family. +* Return TryAgain status in place of Corruption when new tail is not visible to TransactionLogIterator. * Fix a bug caused by secondary not skipping the beginning of new MANIFEST. ## 6.2.0 (4/30/2019) diff --git a/db/transaction_log_impl.cc b/db/transaction_log_impl.cc index 2e4475bb6..8c526af12 100644 --- a/db/transaction_log_impl.cc +++ b/db/transaction_log_impl.cc @@ -199,7 +199,8 @@ void TransactionLogIteratorImpl::NextImpl(bool internal) { if (current_last_seq_ == versions_->LastSequence()) { current_status_ = Status::OK(); } else { - current_status_ = Status::Corruption("NO MORE DATA LEFT"); + const char* msg = "Create a new iterator to fetch the new tail."; + current_status_ = Status::TryAgain(msg); } return; } diff --git a/db/wal_manager_test.cc b/db/wal_manager_test.cc index 1bc6a8afe..671dc84e1 100644 --- a/db/wal_manager_test.cc +++ b/db/wal_manager_test.cc @@ -293,6 +293,29 @@ TEST_F(WalManagerTest, TransactionLogIteratorJustEmptyFile) { // Check that an empty iterator is returned ASSERT_TRUE(!iter->Valid()); } + +TEST_F(WalManagerTest, TransactionLogIteratorNewFileWhileScanning) { + Init(); + CreateArchiveLogs(2, 100); + auto iter = OpenTransactionLogIter(0); + CreateArchiveLogs(1, 100); + int i = 0; + for (; iter->Valid(); iter->Next()) { + i++; + } + ASSERT_EQ(i, 200); + // A new log file was added after the iterator was created. + // TryAgain indicates a new iterator is needed to fetch the new data + ASSERT_TRUE(iter->status().IsTryAgain()); + + iter = OpenTransactionLogIter(0); + i = 0; + for (; iter->Valid(); iter->Next()) { + i++; + } + ASSERT_EQ(i, 300); + ASSERT_TRUE(iter->status().ok()); +} } // namespace rocksdb