From 17f9a181d5a1f936bac8e9c5f411adaaaa5255be Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Fri, 24 Aug 2018 12:21:05 -0700 Subject: [PATCH] Reduce empty SST creation/deletion during compaction (#4311) Summary: I have a PR to start calling `OnTableFileCreated` for empty SSTs: #4307. However, it is a behavior change so should not go into a patch release. This PR adds back a check to make sure range deletions at least exist before starting file creation. This PR should be safe to backport to earlier versions. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4311 Differential Revision: D9493734 Pulled By: ajkr fbshipit-source-id: f0d43cda4cfd904f133cfe3a6eb622f52a9ccbe8 --- HISTORY.md | 1 + db/compaction_job.cc | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 27688d6ac..7fd81aa3f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,6 +5,7 @@ ### New Features ### Bug Fixes +* Avoid creating empty SSTs and subsequently deleting them in certain cases during compaction. ## 5.16.0 (8/21/2018) ### Public API Change diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 3c6f1eefd..ada49103c 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -1077,7 +1077,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { } if (status.ok() && sub_compact->builder == nullptr && - sub_compact->outputs.size() == 0) { + sub_compact->outputs.size() == 0 && + !range_del_agg->IsEmpty()) { // handle subcompaction containing only range deletions status = OpenCompactionOutputFile(sub_compact); }