Skip to content

Commit 4a0c572

Browse files
leveldb Teampwnall
authored andcommitted
Fix TEST_CompactMemTable deadlock
This CL ensures that CompactRange doesn't get stuck on waiting on background_work_finished_signal_ during shutdown. While background_work_finished_signal_ may be in fact signaled, CompactMemTable() will never run, not giving opportunity for workers blocked in TEST_CompactMemTable to exit the loop. We suspect this contributes to b/370844779; while the hang was mitigated by limiting concurrency to 1 worker (which avoids filling the thread pool with blocked workers), this issue can still happen and will block 1 worker during shutdown. PiperOrigin-RevId: 879794057
1 parent 78a352f commit 4a0c572

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

db/db_impl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ Status DBImpl::TEST_CompactMemTable() {
646646
if (s.ok()) {
647647
// Wait until the compaction completes
648648
MutexLock l(&mutex_);
649-
while (imm_ != nullptr && bg_error_.ok()) {
649+
while (imm_ != nullptr && bg_error_.ok() &&
650+
!shutting_down_.load(std::memory_order_acquire)) {
650651
background_work_finished_signal_.Wait();
651652
}
652653
if (imm_ != nullptr) {

0 commit comments

Comments
 (0)