Skip to content

Commit

Permalink
Fix possible crash test segfault in FileExpectedStateManager::Restore…
Browse files Browse the repository at this point in the history
…() (facebook#12314)

Summary:
`replayer` could be `nullptr` if `!s.ok()` from an earlier failure. Also consider status returned from `record->Accept()`.

Pull Request resolved: facebook#12314

Test Plan: blackbox_crash_test run

Reviewed By: hx235

Differential Revision: D53241506

Pulled By: pdillinger

fbshipit-source-id: fd330417c23391ca819c3ee0f69e4156d81934dc
  • Loading branch information
pdillinger authored and facebook-github-bot committed Jan 31, 2024
1 parent 377eee7 commit acf77e1
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions db_stress_tool/expected_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,26 +660,26 @@ Status FileExpectedStateManager::Restore(DB* db) {
if (s.ok()) {
s = replayer->Prepare();
}
for (;;) {
for (; s.ok();) {
std::unique_ptr<TraceRecord> record;
s = replayer->Next(&record);
if (!s.ok()) {
if (s.IsCorruption() && handler->IsDone()) {
// There could be a corruption reading the tail record of the trace
// due to `db_stress` crashing while writing it. It shouldn't matter
// as long as we already found all the write ops we need to catch up
// the expected state.
s = Status::OK();
}
if (s.IsIncomplete()) {
// OK because `Status::Incomplete` is expected upon finishing all the
// trace records.
s = Status::OK();
}
break;
}
std::unique_ptr<TraceRecordResult> res;
record->Accept(handler.get(), &res);
}
if (s.IsCorruption() && handler->IsDone()) {
// There could be a corruption reading the tail record of the trace due to
// `db_stress` crashing while writing it. It shouldn't matter as long as
// we already found all the write ops we need to catch up the expected
// state.
s = Status::OK();
}
if (s.IsIncomplete()) {
// OK because `Status::Incomplete` is expected upon finishing all the
// trace records.
s = Status::OK();
s = record->Accept(handler.get(), &res);
}
}

Expand Down

0 comments on commit acf77e1

Please sign in to comment.