Skip to content

Commit

Permalink
Allow compaction to finish in TEST_CompactRange
Browse files Browse the repository at this point in the history
Waits for a current transaction to finish in TEST_CompactRange when the
`background_work_finished_signal_` signal may be emitted due to an error. This is a prospective fix for flaky crashes observed in b/351680196#comment5.

PiperOrigin-RevId: 663457574
  • Loading branch information
leveldb Team authored and bradtriebwasser committed Aug 16, 2024
1 parent 068d5ee commit eb31d19
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,11 @@ void DBImpl::TEST_CompactRange(int level, const Slice* begin,
background_work_finished_signal_.Wait();
}
}
// Finish current background compaction in the case where
// `background_work_finished_signal_` was signalled due to an error.
while (background_compaction_scheduled_) {
background_work_finished_signal_.Wait();
}
if (manual_compaction_ == &manual) {
// Cancel my manual compaction since we aborted early for some reason.
manual_compaction_ = nullptr;
Expand Down

0 comments on commit eb31d19

Please sign in to comment.