[Rocksdb] Recover last updated sequence number from manifest also.

Summary:
During recovery, last_updated_manifest number was not set if there were no records in the Write-ahead log.
Now check for the recovered manifest also and set last_updated_manifest file to the max value.

Test Plan: unit test

Reviewers: heyongqiang

Reviewed By: heyongqiang

CC: leveldb

Differential Revision: https://reviews.facebook.net/D9891
This commit is contained in:
Abhishek Kona 2013-04-02 17:18:27 -07:00
parent 6763110867
commit ca789a10cc
2 changed files with 15 additions and 3 deletions

View file

@ -549,13 +549,13 @@ Status DBImpl::Recover(VersionEdit* edit, MemTable* external_table,
// update the file number allocation counter in VersionSet.
versions_->MarkFileNumberUsed(logs[i]);
}
// This could be the last_flushed_sequence as the next sequences will be
// greater than this.
last_flushed_sequence_ = max_sequence;
if (s.ok()) {
if (versions_->LastSequence() < max_sequence) {
versions_->SetLastSequence(max_sequence);
last_flushed_sequence_ = max_sequence;
} else {
last_flushed_sequence_ = versions_->LastSequence();
}
}
}

View file

@ -2688,6 +2688,18 @@ TEST(DBTest, TransactionLogIteratorJustEmptyFile) {
Status status = dbfull()->GetUpdatesSince(0, &iter);
ASSERT_TRUE(!status.ok());
}
TEST(DBTest, TransactionLogIteratorCheckAfterRestart) {
Options options = OptionsForLogIterTest();
DestroyAndReopen(&options);
Put("key1", DummyString(1024));
Put("key2", DummyString(1023));
dbfull()->Flush(FlushOptions());
Reopen(&options);
auto iter = OpenTransactionLogIter(0);
ExpectRecords(2, iter);
}
TEST(DBTest, ReadCompaction) {
std::string value(4096, '4'); // a string of size 4K
{