Track WAL in MANIFEST: minor udpates (#7282)
Summary: The updates resolve comments left from https://github.com/facebook/rocksdb/pull/7164. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7282 Test Plan: wal_edit_test Reviewed By: ltamasi Differential Revision: D23196824 Pulled By: cheng-chang fbshipit-source-id: 797f3fef27fc72114c2be777d9eadd3429da5301
This commit is contained in:
parent
327ddb7d47
commit
ce4192375d
@ -126,7 +126,7 @@ Status WalSet::AddWal(const WalAddition& wal) {
|
||||
ss << "WAL " << wal.GetLogNumber() << " is created more than once";
|
||||
return Status::Corruption("WalSet", ss.str());
|
||||
}
|
||||
wals_[wal.GetLogNumber()] = wal.GetMetadata();
|
||||
wals_.insert(it, {wal.GetLogNumber(), wal.GetMetadata()});
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
@ -143,9 +143,9 @@ Status WalSet::AddWals(const WalAdditions& wals) {
|
||||
}
|
||||
|
||||
Status WalSet::DeleteWal(const WalDeletion& wal) {
|
||||
auto it = wals_.lower_bound(wal.GetLogNumber());
|
||||
auto it = wals_.find(wal.GetLogNumber());
|
||||
// The WAL must exist and has been closed.
|
||||
if (it == wals_.end() || it->first != wal.GetLogNumber()) {
|
||||
if (it == wals_.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "WAL " << wal.GetLogNumber() << " must exist before deletion";
|
||||
return Status::Corruption("WalSet", ss.str());
|
||||
|
@ -109,10 +109,10 @@ TEST(WalSet, DeleteNonExistingWal) {
|
||||
}
|
||||
|
||||
TEST(WalSet, DeleteNonClosedWal) {
|
||||
constexpr WalNumber kNonExistingNumber = 100;
|
||||
constexpr WalNumber kNonClosedWalNumber = 100;
|
||||
WalSet wals;
|
||||
ASSERT_OK(wals.AddWal(WalAddition(kNonExistingNumber)));
|
||||
Status s = wals.DeleteWal(WalDeletion(kNonExistingNumber));
|
||||
ASSERT_OK(wals.AddWal(WalAddition(kNonClosedWalNumber)));
|
||||
Status s = wals.DeleteWal(WalDeletion(kNonClosedWalNumber));
|
||||
ASSERT_TRUE(s.IsCorruption());
|
||||
ASSERT_TRUE(s.ToString().find("WAL 100 must be closed before deletion") !=
|
||||
std::string::npos);
|
||||
|
Loading…
Reference in New Issue
Block a user