From d74c9f0a5714f29d723a845b166dba517ce7abc1 Mon Sep 17 00:00:00 2001 From: Venkatesh Radhakrishnan Date: Mon, 4 Jan 2016 10:55:31 -0800 Subject: [PATCH] DeleteFilesInRange: Clean job context if no files deleted Summary: We need to clean the job context if we end up not deleting any files because no files are in the range specified. Test Plan: DBCompactionTest.DeleteFileRange Reviewers: sdong, anthony, yhchiang, kradhakrishnan, IslamAbdelRahman Reviewed By: IslamAbdelRahman Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D52467 --- db/db_compaction_test.cc | 7 +++++++ db/db_impl.cc | 1 + 2 files changed, 8 insertions(+) diff --git a/db/db_compaction_test.cc b/db/db_compaction_test.cc index 3224e9a51..a28edd394 100644 --- a/db/db_compaction_test.cc +++ b/db/db_compaction_test.cc @@ -1230,6 +1230,13 @@ TEST_F(DBCompactionTest, DeleteFileRange) { } } ASSERT_GT(deleted_count, 0); + begin_string = Key(5000); + end_string = Key(6000); + Slice begin1(begin_string); + Slice end1(end_string); + // Try deleting files in range which contain no keys + ASSERT_OK( + DeleteFilesInRange(db_, db_->DefaultColumnFamily(), &begin1, &end1)); ASSERT_OK( DeleteFilesInRange(db_, db_->DefaultColumnFamily(), nullptr, nullptr)); diff --git a/db/db_impl.cc b/db/db_impl.cc index 661e3b48a..4960c19cb 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -5056,6 +5056,7 @@ Status DBImpl::DeleteFilesInRange(ColumnFamilyHandle* column_family, } } if (edit.GetDeletedFiles().empty()) { + job_context.Clean(); return Status::OK(); } status = versions_->LogAndApply(cfd, *cfd->GetLatestMutableCFOptions(),