-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a bug with auto recovery on WAL write error #12995
Closed
Closed
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,16 +381,16 @@ void ErrorHandler::HandleKnownErrors(const Status& bg_err, | |
// BackgroundErrorReason reason) will be called to handle other error cases | ||
// such as delegating to SstFileManager to handle no space error. | ||
void ErrorHandler::SetBGError(const Status& bg_status, | ||
BackgroundErrorReason reason) { | ||
BackgroundErrorReason reason, bool wal_related) { | ||
db_mutex_->AssertHeld(); | ||
Status tmp_status = bg_status; | ||
IOStatus bg_io_err = status_to_io_status(std::move(tmp_status)); | ||
|
||
if (bg_io_err.ok()) { | ||
return; | ||
} | ||
ROCKS_LOG_WARN(db_options_.info_log, "Background IO error %s", | ||
bg_io_err.ToString().c_str()); | ||
ROCKS_LOG_WARN(db_options_.info_log, "Background IO error %s, reason %d", | ||
bg_io_err.ToString().c_str(), static_cast<int>(reason)); | ||
|
||
RecordStats({ERROR_HANDLER_BG_ERROR_COUNT, ERROR_HANDLER_BG_IO_ERROR_COUNT}, | ||
{} /* int_histograms */); | ||
|
@@ -412,6 +412,31 @@ void ErrorHandler::SetBGError(const Status& bg_status, | |
recover_context_ = context; | ||
return; | ||
} | ||
if (wal_related) { | ||
assert(reason == BackgroundErrorReason::kWriteCallback || | ||
reason == BackgroundErrorReason::kMemTable || | ||
reason == BackgroundErrorReason::kFlush); | ||
} | ||
if (db_options_.manual_wal_flush && wal_related && bg_io_err.IsIOError()) { | ||
// TODO: remove parameter `wal_related` once we can automatically recover | ||
// from WAL write failure. | ||
// We should not try auto recover IOError from writing to WAL . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: once we fix the bug in automatically recovery from WAL write failure. Before that, we should not try auto recovery IOError .... |
||
// With manual_wal_flush, a WAL write failure can drop buffered WAL writes. | ||
// Memtables and WAL may not be consistent. A successful memtable flush on | ||
// one CF can cause CFs to be inconsistent upon restart. Set the error | ||
// severity to fatal to disallow resume. | ||
bool auto_recovery = false; | ||
Status bg_err(new_bg_io_err, Status::Severity::kFatalError); | ||
CheckAndSetRecoveryAndBGError(bg_err); | ||
ROCKS_LOG_WARN(db_options_.info_log, | ||
"ErrorHandler: A potentially WAL error happened, set " | ||
"background IO error as fatal error\n"); | ||
EventHelpers::NotifyOnBackgroundError(db_options_.listeners, reason, | ||
&bg_err, db_mutex_, &auto_recovery); | ||
recover_context_ = context; | ||
return; | ||
} | ||
|
||
if (bg_io_err.subcode() != IOStatus::SubCode::kNoSpace && | ||
(bg_io_err.GetScope() == IOStatus::IOErrorScope::kIOErrorScopeFile || | ||
bg_io_err.GetRetryable())) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Fix a bug with manual_wal_flush and auto error recovery from WAL failure that may cause CFs to be inconsistent (#12995). The fix will set potential WAL write failure as fatal error when manual_wal_flush is true, and disables auto error recovery from these errors. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"// Sets bg error if there is an error writing to WAL." is this comment for SyncClosedWals or WALIOStatusCheck?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's meant for SyncClosedWals(). Just to emphasis that this function will set bg error.