Replace Corruption with TryAgain status when new tail is not visible to TransactionLogIterator (#5474)

Summary:
When tailing the WAL with TransactionLogIterator, it used to return Corruption status to indicate that the WAL has new tail that is not visible to the iterator, which is a misleading status. The patch replaces it with TryAgain which is more descriptive of a status, indicating that the user needs to create a new iterator to fetch the recent tail.
Fixes https://github.com/facebook/rocksdb/issues/5455
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5474

Differential Revision: D15898953

Pulled By: maysamyabandeh

fbshipit-source-id: 40966f6457cb539e1aeb104daeada6b0e46059fc
This commit is contained in:
Simon Grätzer 2019-06-19 08:02:21 -07:00 committed by Facebook Github Bot
parent 5355e527d9
commit fe90ed7a70
3 changed files with 26 additions and 1 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -294,6 +294,29 @@ TEST_F(WalManagerTest, TransactionLogIteratorJustEmptyFile) {
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
int main(int argc, char** argv) {