diff --git a/HISTORY.md b/HISTORY.md index e9f06b5328092ceac506c87288b1bfb06820c397..b65f5a038b1bf28f32f158a781970f66f0fc857b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -13,6 +13,7 @@ * DBIter::Next() can skip user key checking if previous entry's seqnum is 0. * Merging iterator to avoid child iterator reseek for some cases * Reduce iterator key comparision for upper/lower bound check. +* Log Writer will flush after finishing the whole record, rather than a fragment. ### General Improvements * Added new status code kColumnFamilyDropped to distinguish between Column Family Dropped and DB Shutdown in progress. diff --git a/db/log_writer.cc b/db/log_writer.cc index 6ee39198184f64df21eb4373f58f7d07ba4dd6f8..c46965e16e0ab2dd68994e8cc84551fe2c3cb1a4 100644 --- a/db/log_writer.cc +++ b/db/log_writer.cc @@ -102,6 +102,13 @@ Status Writer::AddRecord(const Slice& slice) { left -= fragment_length; begin = false; } while (s.ok() && left > 0); + + if (s.ok()) { + if (!manual_flush_) { + s = dest_->Flush(); + } + } + return s; } @@ -146,11 +153,6 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) { Status s = dest_->Append(Slice(buf, header_size)); if (s.ok()) { s = dest_->Append(Slice(ptr, n)); - if (s.ok()) { - if (!manual_flush_) { - s = dest_->Flush(); - } - } } block_offset_ += header_size + n; return s;