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
main
Igor Canadi 11 years ago
parent dea894ef8d
commit 4209516359
  1. 7
      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<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();

Loading…
Cancel
Save