Skip to content

Commit 70bb732

Browse files
committed
fix
1 parent 618f660 commit 70bb732

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

db/error_handler.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,17 @@ void ErrorHandler::SetBGError(const Status& bg_status,
423423
reason == BackgroundErrorReason::kMemTable ||
424424
reason == BackgroundErrorReason::kFlush);
425425
}
426-
if (db_options_.manual_wal_flush && wal_related && bg_io_err.IsIOError()) {
427-
// With manual_wal_flush, a WAL write failure can drop buffered WAL writes.
428-
// Memtables and WAL then become inconsistent. A successful memtable flush
429-
// on one CF can cause CFs to be inconsistent upon restart. Before we fix
430-
// the bug in auto recovery from WAL write failures that can flush one CF
431-
// at a time, we set the error severity to fatal to disallow auto recovery.
432-
// TODO: remove parameter `wal_related` once we can automatically recover
433-
// from WAL write failures.
426+
427+
// When `atomic_flush = false` with multiple column families, when
428+
// encountering WAL related IO error, individual CF flushing during auto
429+
// recovery can create data inconsistencies where some column families advance
430+
// past the corruption point while others remain behind, preventing successful
431+
// database restart. Therefore we disable auto recovery by setting a higher
432+
// severity `Status::Severity::kFatalError`.
433+
bool has_multiple_cfs =
434+
db_->versions_->GetColumnFamilySet()->NumberOfColumnFamilies() > 1;
435+
if (!db_options_.atomic_flush && has_multiple_cfs && wal_related &&
436+
bg_io_err.IsIOError()) {
434437
bool auto_recovery = false;
435438
Status bg_err(new_bg_io_err, Status::Severity::kFatalError);
436439
CheckAndSetRecoveryAndBGError(bg_err);

db_stress_tool/db_stress_test_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class StressTest {
354354
assert(!error_s.ok());
355355
return error_s.getState() &&
356356
FaultInjectionTestFS::IsInjectedError(error_s) &&
357-
!status_to_io_status(Status(error_s)).GetDataLoss();
357+
!status_to_io_status(Status(error_s)).GetDataLoss() &&
358+
error_s.severity() <= Status::Severity::kHardError;
358359
}
359360

360361
void ProcessStatus(SharedState* shared, std::string msg, const Status& s,

tools/db_crashtest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ def finalize_and_sanitize(src_params):
994994
if (
995995
dest_params.get("reopen") > 0
996996
or (
997-
dest_params.get("manual_wal_flush_one_in")
997+
dest_params.get("atomic_flush") != 1
998998
and dest_params.get("column_families") != 1
999999
)
10001000
or (
@@ -1008,10 +1008,10 @@ def finalize_and_sanitize(src_params):
10081008
# To simplify, we disable any WAL write error injection.
10091009
# TODO(hx235): support WAL write error injection with reopen
10101010
#
1011-
# 2. WAL write failure can drop buffered WAL data. This can cause
1012-
# inconsistency when one CF has a successful flush during auto
1013-
# recovery. Disable the fault injection in this path for now until
1014-
# we have a fix that allows auto recovery.
1011+
# 2. When `atomic_flush = false` with multiple column families, when encountering WAL related IO error,
1012+
# individual CF flushing during auto recovery can create data inconsistencies where some column families advance
1013+
# past the corruption point while others remain behind, preventing successful database restart.
1014+
# Therefore we disable auto recovery and testing for this case in crash test
10151015
#
10161016
# 3. Pessimistic transactions use 2PC, which can't auto-recover from WAL write errors.
10171017
# This is because RocksDB cannot easily discard the corrupted WAL without risking the

0 commit comments

Comments
 (0)