From 4209516359860ed4da676f217a648c5ce932d743 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 25 Feb 2014 12:04:14 -0800 Subject: [PATCH] Schedule flush when waiting on flush Summary: This will also help with avoiding the deadlock. If a flush failed and we're waiting for a memtable to be flushed, we should schedule a new flush and hope a new one succeedes. If paranoid_checks = false, Wait() will still hang on ENOSPC, but at least it will automatically continue when the space frees up. Current behavior both hangs and deadlocks. Also, I renamed some 'compaction' to 'flush'. 'compaction' was leveldb way of saying things. Test Plan: make check Reviewers: dhruba, haobo, ljin Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D16281 --- db/db_impl.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 12042585b..b1ce96e1b 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3364,9 +3364,10 @@ Status DBImpl::MakeRoomForWrite(bool force, break; } else if (imm_.size() == options_.max_write_buffer_number - 1) { // We have filled up the current memtable, but the previous - // ones are still being compacted, so we wait. + // ones are still being flushed, so we wait. DelayLoggingAndReset(); - Log(options_.info_log, "wait for memtable compaction...\n"); + Log(options_.info_log, "wait for memtable flush...\n"); + MaybeScheduleFlushOrCompaction(); uint64_t stall; { StopWatch sw(env_, options_.statistics.get(), @@ -3440,7 +3441,7 @@ Status DBImpl::MakeRoomForWrite(bool force, unique_ptr lfile; MemTable* new_mem = nullptr; - // Attempt to switch to a new memtable and trigger compaction of old. + // Attempt to switch to a new memtable and trigger flush of old. // Do this without holding the dbmutex lock. assert(versions_->PrevLogNumber() == 0); uint64_t new_log_number = versions_->NewFileNumber();