提交 13035735 编写于 作者: C chuhao zeng 提交者: Facebook GitHub Bot

Reverse sort order in dedup to enable iter checking in callback (#11725)

Summary:
Fix https://github.com/facebook/rocksdb/issues/6470

Ensure TransactionLogIter being initialized correctly with SYNC_POINT API when calling `GetSortedWALFiles`.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11725

Reviewed By: akankshamahajan15

Differential Revision: D48529411

Pulled By: ajkr

fbshipit-source-id: 970ca1a6259ed996c6d87f7fcd40f95acf441517
上级 5e0584bd
......@@ -457,12 +457,12 @@ void DBImpl::PurgeObsoleteFiles(JobContext& state, bool schedule_only) {
std::sort(candidate_files.begin(), candidate_files.end(),
[](const JobContext::CandidateFileInfo& lhs,
const JobContext::CandidateFileInfo& rhs) {
if (lhs.file_name > rhs.file_name) {
if (lhs.file_name < rhs.file_name) {
return true;
} else if (lhs.file_name < rhs.file_name) {
} else if (lhs.file_name > rhs.file_name) {
return false;
} else {
return (lhs.file_path > rhs.file_path);
return (lhs.file_path < rhs.file_path);
}
});
candidate_files.erase(
......
......@@ -145,6 +145,41 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorRace) {
} while (ChangeCompactOptions());
}
}
TEST_F(DBTestXactLogIterator, TransactionLogIteratorCheckWhenArchive) {
do {
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearTrace();
Options options = OptionsForLogIterTest();
DestroyAndReopen(options);
ColumnFamilyHandle* cf;
auto s = dbfull()->CreateColumnFamily(ColumnFamilyOptions(), "CF", &cf);
ASSERT_TRUE(s.ok());
ASSERT_OK(dbfull()->Put(WriteOptions(), cf, "key1", DummyString(1024)));
ASSERT_OK(dbfull()->Put(WriteOptions(), "key2", DummyString(1024)));
ASSERT_OK(dbfull()->Flush(FlushOptions()));
ASSERT_OK(dbfull()->Put(WriteOptions(), "key3", DummyString(1024)));
ASSERT_OK(dbfull()->Flush(FlushOptions()));
ASSERT_OK(dbfull()->Put(WriteOptions(), "key4", DummyString(1024)));
ASSERT_OK(dbfull()->Flush(FlushOptions()));
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WalManager::PurgeObsoleteFiles:1", [&](void*) {
auto iter = OpenTransactionLogIter(0);
ExpectRecords(4, iter);
});
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->Flush(FlushOptions(), cf));
delete cf;
} while (ChangeCompactOptions());
}
#endif
TEST_F(DBTestXactLogIterator, TransactionLogIteratorStallAtLastRecord) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册