From b3c0c0939987260523fff12d2ae17cbd5fc2249a Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Thu, 26 Dec 2024 14:01:12 -0800 Subject: [PATCH] fix --- db/db_impl/db_impl.cc | 9 +++++---- db/error_handler.cc | 2 ++ db/version_set.cc | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 3bc2be1f0472..6dc6f78643a8 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -1300,11 +1300,12 @@ Status DBImpl::SetOptions( VersionEdit dummy_edit; s = versions_->LogAndApply(cfd, new_options, read_options, write_options, &dummy_edit, &mutex_, directories_.GetDbDir()); - // Trigger possible flush/compactions. This has to be before we persist - // options to file, otherwise there will be a deadlock with writer - // thread. + if (!versions_->io_status().ok()) { + assert(!s.ok()); + error_handler_.SetBGError(versions_->io_status(), + BackgroundErrorReason::kManifestWrite); + } InstallSuperVersionAndScheduleWork(cfd, &sv_context, new_options); - persist_options_status = WriteOptionsFile(write_options, true /*db_mutex_already_held*/); bg_cv_.SignalAll(); diff --git a/db/error_handler.cc b/db/error_handler.cc index 2a8a7dee5e6b..d014d2897d11 100644 --- a/db/error_handler.cc +++ b/db/error_handler.cc @@ -573,6 +573,8 @@ Status ErrorHandler::ClearBGError() { // Signal that recovery succeeded if (recovery_error_.ok()) { + // If this assertion fails, it means likely bg error is not set after a + // file is quarantined during MANIFEST write. assert(files_to_quarantine_.empty()); Status old_bg_error = bg_error_; // old_bg_error is only for notifying listeners, so may not be checked diff --git a/db/version_set.cc b/db/version_set.cc index 02a046c6f66c..889cc94d5f8b 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -5939,6 +5939,8 @@ Status VersionSet::LogAndApply( } TEST_SYNC_POINT_CALLBACK("VersionSet::LogAndApply:WakeUpAndDone", mu); #endif /* !NDEBUG */ + // FIXME: One MANIFEST write failure can cause all writes to SetBGError, + // should only SetBGError once. return first_writer.status; }