Skip to content

Commit

Permalink
Fix rare WAL handling crash (facebook#12899)
Browse files Browse the repository at this point in the history
Summary:
A crash test failure in log sync in DBImpl::WriteToWAL is due to a missed case in facebook#12734. Just need to apply similar logic from DBImpl::SyncWalImpl to check for an already closed WAL (nullptr writer). This is extremely rare because it only comes from failed Sync on a closed WAL.

Pull Request resolved: facebook#12899

Test Plan: watch crash test

Reviewed By: cbi42

Differential Revision: D60481652

Pulled By: pdillinger

fbshipit-source-id: 4a176bb6a53dcf077f88344710a110c2f946c386
  • Loading branch information
pdillinger authored and facebook-github-bot committed Jul 31, 2024
1 parent 55877d8 commit 2595476
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions db/db_impl/db_impl_write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,14 @@ IOStatus DBImpl::WriteToWAL(const WriteThread::WriteGroup& write_group,
if (!io_s.ok()) {
break;
}
io_s = log.writer->file()->Sync(opts, immutable_db_options_.use_fsync);
if (!io_s.ok()) {
break;
// If last sync failed on a later WAL, this could be a fully synced
// and closed WAL that just needs to be recorded as synced in the
// manifest.
if (auto* f = log.writer->file()) {
io_s = f->Sync(opts, immutable_db_options_.use_fsync);
if (!io_s.ok()) {
break;
}
}
}
}
Expand Down

0 comments on commit 2595476

Please sign in to comment.