mirror of https://github.com/facebook/rocksdb.git
Ignore shutdown error during compaction (#5400)
Summary: The PR #5275 separated the column dropped and shutdown status codes. However, there were a couple of places in compaction where this change ended up treating a ShutdownInProgress() error as a real error and set bg_error. This caused MyRocks unit test to fail due to WAL writes during shutdown returning this error. Fix it by ignoring the shutdown status during compaction. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5400 Differential Revision: D15611680 Pulled By: anand1976 fbshipit-source-id: c602e97840e3ae24eb420d61e0ce95d3e6258632
This commit is contained in:
parent
ae05a83e19
commit
5d6e8df1cf
|
@ -4557,6 +4557,36 @@ TEST_F(DBCompactionTest, ManualCompactionBottomLevelOptimized) {
|
||||||
ASSERT_EQ(num, 0);
|
ASSERT_EQ(num, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DBCompactionTest, CompactionDuringShutdown) {
|
||||||
|
Options opts = CurrentOptions();
|
||||||
|
opts.level0_file_num_compaction_trigger = 2;
|
||||||
|
opts.disable_auto_compactions = true;
|
||||||
|
DestroyAndReopen(opts);
|
||||||
|
ColumnFamilyHandleImpl* cfh =
|
||||||
|
static_cast<ColumnFamilyHandleImpl*>(dbfull()->DefaultColumnFamily());
|
||||||
|
ColumnFamilyData* cfd = cfh->cfd();
|
||||||
|
InternalStats* internal_stats_ptr = cfd->internal_stats();
|
||||||
|
ASSERT_NE(internal_stats_ptr, nullptr);
|
||||||
|
|
||||||
|
Random rnd(301);
|
||||||
|
for (auto i = 0; i < 2; ++i) {
|
||||||
|
for (auto j = 0; j < 10; ++j) {
|
||||||
|
ASSERT_OK(
|
||||||
|
Put("foo" + std::to_string(i * 10 + j), RandomString(&rnd, 1024)));
|
||||||
|
}
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
rocksdb::SyncPoint::GetInstance()->SetCallBack(
|
||||||
|
"DBImpl::BackgroundCompaction:NonTrivial:BeforeRun",
|
||||||
|
[&](void* /*arg*/) {
|
||||||
|
dbfull()->shutting_down_.store(true);
|
||||||
|
});
|
||||||
|
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
|
||||||
|
dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
|
||||||
|
ASSERT_OK(dbfull()->error_handler_.GetBGError());
|
||||||
|
}
|
||||||
|
|
||||||
// FixFileIngestionCompactionDeadlock tests and verifies that compaction and
|
// FixFileIngestionCompactionDeadlock tests and verifies that compaction and
|
||||||
// file ingestion do not cause deadlock in the event of write stall triggered
|
// file ingestion do not cause deadlock in the event of write stall triggered
|
||||||
// by number of L0 files reaching level0_stop_writes_trigger.
|
// by number of L0 files reaching level0_stop_writes_trigger.
|
||||||
|
|
|
@ -1000,6 +1000,7 @@ class DBImpl : public DB {
|
||||||
friend class DBTest_ConcurrentFlushWAL_Test;
|
friend class DBTest_ConcurrentFlushWAL_Test;
|
||||||
friend class DBTest_MixedSlowdownOptionsStop_Test;
|
friend class DBTest_MixedSlowdownOptionsStop_Test;
|
||||||
friend class DBCompactionTest_CompactBottomLevelFilesWithDeletions_Test;
|
friend class DBCompactionTest_CompactBottomLevelFilesWithDeletions_Test;
|
||||||
|
friend class DBCompactionTest_CompactionDuringShutdown_Test;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
friend class DBTest2_ReadCallbackTest_Test;
|
friend class DBTest2_ReadCallbackTest_Test;
|
||||||
friend class WriteCallbackTest_WriteWithCallbackTest_Test;
|
friend class WriteCallbackTest_WriteWithCallbackTest_Test;
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ Status DBImpl::CompactFilesImpl(
|
||||||
|
|
||||||
if (status.ok()) {
|
if (status.ok()) {
|
||||||
// Done
|
// Done
|
||||||
} else if (status.IsColumnFamilyDropped()) {
|
} else if (status.IsColumnFamilyDropped() || status.IsShutdownInProgress()) {
|
||||||
// Ignore compaction errors found during shutting down
|
// Ignore compaction errors found during shutting down
|
||||||
} else {
|
} else {
|
||||||
ROCKS_LOG_WARN(immutable_db_options_.info_log,
|
ROCKS_LOG_WARN(immutable_db_options_.info_log,
|
||||||
|
@ -2680,6 +2680,8 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
|
||||||
compaction_job_stats, job_context->job_id);
|
compaction_job_stats, job_context->job_id);
|
||||||
|
|
||||||
mutex_.Unlock();
|
mutex_.Unlock();
|
||||||
|
TEST_SYNC_POINT_CALLBACK(
|
||||||
|
"DBImpl::BackgroundCompaction:NonTrivial:BeforeRun", nullptr);
|
||||||
compaction_job.Run();
|
compaction_job.Run();
|
||||||
TEST_SYNC_POINT("DBImpl::BackgroundCompaction:NonTrivial:AfterRun");
|
TEST_SYNC_POINT("DBImpl::BackgroundCompaction:NonTrivial:AfterRun");
|
||||||
mutex_.Lock();
|
mutex_.Lock();
|
||||||
|
@ -2713,7 +2715,7 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
|
||||||
|
|
||||||
if (status.ok() || status.IsCompactionTooLarge()) {
|
if (status.ok() || status.IsCompactionTooLarge()) {
|
||||||
// Done
|
// Done
|
||||||
} else if (status.IsColumnFamilyDropped()) {
|
} else if (status.IsColumnFamilyDropped() || status.IsShutdownInProgress()) {
|
||||||
// Ignore compaction errors found during shutting down
|
// Ignore compaction errors found during shutting down
|
||||||
} else {
|
} else {
|
||||||
ROCKS_LOG_WARN(immutable_db_options_.info_log, "Compaction error: %s",
|
ROCKS_LOG_WARN(immutable_db_options_.info_log, "Compaction error: %s",
|
||||||
|
|
Loading…
Reference in New Issue