Fix an assertion failure when ManifestTailer switches to new Manifest in multi-cf mode (#9143)
Summary: Original unit test fail to test the case of multi-cf mode switching to new manifest. The assertion failure will trigger when the primary instance reopens and secondary continues to tail the newly-created MANIFEST. Fix the assertion failure and update existing unit tests. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9143 Test Plan: make check Reviewed By: ltamasi Differential Revision: D32574233 Pulled By: riversand963 fbshipit-source-id: 857ddbe994019091276458abebcf8e2b65340468
This commit is contained in:
parent
dc5de45af8
commit
43ac7a2774
@ -22,6 +22,7 @@
|
||||
* Explicitly check for and disallow the `BlockBasedTableOptions` if insertion into one of {`block_cache`, `block_cache_compressed`, `persistent_cache`} can show up in another of these. (RocksDB expects to be able to use the same key for different physical data among tiers.)
|
||||
* Users who configured a dedicated thread pool for bottommost compactions by explicitly adding threads to the `Env::Priority::BOTTOM` pool will no longer see RocksDB schedule automatic compactions exceeding the DB's compaction concurrency limit. For details on per-DB compaction concurrency limit, see API docs of `max_background_compactions` and `max_background_jobs`.
|
||||
* Fixed a bug of background flush thread picking more memtables to flush and prematurely advancing column family's log_number.
|
||||
* Fixed an assertion failure in ManifestTailer.
|
||||
|
||||
### Behavior Changes
|
||||
* `NUM_FILES_IN_SINGLE_COMPACTION` was only counting the first input level files, now it's including all input files.
|
||||
|
@ -851,12 +851,14 @@ TEST_F(DBSecondaryTest, SwitchManifest) {
|
||||
Options options;
|
||||
options.env = env_;
|
||||
options.level0_file_num_compaction_trigger = 4;
|
||||
Reopen(options);
|
||||
const std::string cf1_name("test_cf");
|
||||
CreateAndReopenWithCF({cf1_name}, options);
|
||||
|
||||
Options options1;
|
||||
options1.env = env_;
|
||||
options1.max_open_files = -1;
|
||||
OpenSecondary(options1);
|
||||
OpenSecondaryWithColumnFamilies({kDefaultColumnFamilyName, cf1_name},
|
||||
options1);
|
||||
|
||||
const int kNumFiles = options.level0_file_num_compaction_trigger - 1;
|
||||
// Keep it smaller than 10 so that key0, key1, ..., key9 are sorted as 0, 1,
|
||||
@ -890,11 +892,11 @@ TEST_F(DBSecondaryTest, SwitchManifest) {
|
||||
// restart primary, performs full compaction, close again, restart again so
|
||||
// that next time secondary tries to catch up with primary, the secondary
|
||||
// will skip the MANIFEST in middle.
|
||||
Reopen(options);
|
||||
ReopenWithColumnFamilies({kDefaultColumnFamilyName, cf1_name}, options);
|
||||
ASSERT_OK(dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
ASSERT_OK(dbfull()->TEST_WaitForCompact());
|
||||
|
||||
Reopen(options);
|
||||
ReopenWithColumnFamilies({kDefaultColumnFamilyName, cf1_name}, options);
|
||||
ASSERT_OK(dbfull()->SetOptions({{"disable_auto_compactions", "false"}}));
|
||||
|
||||
ASSERT_OK(db_secondary_->TryCatchUpWithPrimary());
|
||||
@ -905,12 +907,14 @@ TEST_F(DBSecondaryTest, SwitchManifestTwice) {
|
||||
Options options;
|
||||
options.env = env_;
|
||||
options.disable_auto_compactions = true;
|
||||
Reopen(options);
|
||||
const std::string cf1_name("test_cf");
|
||||
CreateAndReopenWithCF({cf1_name}, options);
|
||||
|
||||
Options options1;
|
||||
options1.env = env_;
|
||||
options1.max_open_files = -1;
|
||||
OpenSecondary(options1);
|
||||
OpenSecondaryWithColumnFamilies({kDefaultColumnFamilyName, cf1_name},
|
||||
options1);
|
||||
|
||||
ASSERT_OK(Put("0", "value0"));
|
||||
ASSERT_OK(Flush());
|
||||
@ -921,9 +925,9 @@ TEST_F(DBSecondaryTest, SwitchManifestTwice) {
|
||||
ASSERT_OK(db_secondary_->Get(ropts, "0", &value));
|
||||
ASSERT_EQ("value0", value);
|
||||
|
||||
Reopen(options);
|
||||
ReopenWithColumnFamilies({kDefaultColumnFamilyName, cf1_name}, options);
|
||||
ASSERT_OK(dbfull()->SetOptions({{"disable_auto_compactions", "false"}}));
|
||||
Reopen(options);
|
||||
ReopenWithColumnFamilies({kDefaultColumnFamilyName, cf1_name}, options);
|
||||
ASSERT_OK(Put("0", "value1"));
|
||||
ASSERT_OK(db_secondary_->TryCatchUpWithPrimary());
|
||||
|
||||
|
@ -638,6 +638,11 @@ void VersionEditHandlerPointInTime::CheckIterationResult(
|
||||
versions_.erase(v_iter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const auto& elem : versions_) {
|
||||
delete elem.second;
|
||||
}
|
||||
versions_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -874,7 +879,7 @@ Status ManifestTailer::OnColumnFamilyAdd(VersionEdit& edit,
|
||||
|
||||
#ifndef NDEBUG
|
||||
auto version_iter = versions_.find(edit.GetColumnFamily());
|
||||
assert(version_iter != versions_.end());
|
||||
assert(version_iter == versions_.end());
|
||||
#endif // !NDEBUG
|
||||
return Status::OK();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user