From 0ef628537c52a655eba1c2bf3e2f4cb34f923062 Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Mon, 11 Nov 2013 21:05:16 -0800 Subject: [PATCH] Don't not suggest flushing data when data block is still empty Summary: This diff fix the bug when the Options::block_size is too small. --- table/flush_block_policy.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/table/flush_block_policy.cc b/table/flush_block_policy.cc index 7b5254532..a953a78a7 100644 --- a/table/flush_block_policy.cc +++ b/table/flush_block_policy.cc @@ -28,6 +28,11 @@ class FlushBlockBySizePolicy : public FlushBlockPolicy { virtual bool Update(const Slice& key, const Slice& value) override { + // it makes no sense to flush when the data block is empty + if (data_block_builder_.empty()) { + return false; + } + auto curr_size = data_block_builder_.CurrentSizeEstimate(); // Do flush if one of the below two conditions is true: