]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Update compaction score right after CompactFiles forms a compaction
authorYueh-Hsuan Chiang <yhchiang@fb.com>
Thu, 10 Mar 2016 22:34:28 +0000 (14:34 -0800)
committerAndrew Kryczka <andrewkr@fb.com>
Mon, 14 Mar 2016 18:11:09 +0000 (11:11 -0700)
Summary:
This is a follow-up patch of https://reviews.facebook.net/D54891.
As the information about files being compacted will also be used
when making compaction decision, it is necessary to update the compaction
score when a compaction plan has been made but not yet execute.

This patch adds a missing call to update the compaction score in
CompactFiles().

Test Plan: compact_files_test

Reviewers: sdong, IslamAbdelRahman, kradhakrishnan, yiwu, andrewkr

Reviewed By: andrewkr

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D55227

db/db_impl.cc

index ebcbe1a4e4bc23a3db09ca1ef9b84a0638aa0133..675669ad21a5a5e178a0638b2a3fa55c08cc67b6 100644 (file)
@@ -1844,6 +1844,17 @@ Status DBImpl::CompactFilesImpl(
                  // support for CompactFiles, we should have CompactFiles API
                  // pass a pointer of CompactionJobStats as the out-value
                  // instead of using EventListener.
+
+  // Creating a compaction influences the compaction score because the score
+  // takes running compactions into account (by skipping files that are already
+  // being compacted). Since we just changed compaction score, we recalculate it
+  // here.
+  {
+    CompactionOptionsFIFO dummy_compaction_options_fifo;
+    version->storage_info()->ComputeCompactionScore(
+        *c->mutable_cf_options(), dummy_compaction_options_fifo);
+  }
+
   compaction_job.Prepare();
 
   mutex_.Unlock();