Skip to content

Commit

Permalink
Schedule flush when waiting on flush
Browse files Browse the repository at this point in the history
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
  • Loading branch information
igorcanadi committed Feb 25, 2014
1 parent dea894e commit 4209516
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -3440,7 +3441,7 @@ Status DBImpl::MakeRoomForWrite(bool force,
unique_ptr<WritableFile> 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();
Expand Down

0 comments on commit 4209516

Please sign in to comment.