From a3b8c76d8e3f2a849d354280e9baaac6728a8b4d Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Thu, 13 Jun 2019 14:38:54 -0700 Subject: [PATCH] Add missing check before calling PurgeObsoleteFiles in EnableFileDeletions (#5448) Summary: Calling PurgeObsoleteFiles with a JobContext for which HaveSomethingToDelete is false is a precondition violation. This would trigger an assertion in debug builds; however, in release builds with assertions disabled, this can result in the pending_purge_obsolete_files_ counter in DBImpl underflowing, which in turn can lead to the process hanging during database close. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5448 Differential Revision: D15792569 Pulled By: ltamasi fbshipit-source-id: 82d92c9b4f6a9efcdc69dbb3d5a52a1ae2dd2472 --- db/db_filesnapshot.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/db_filesnapshot.cc b/db/db_filesnapshot.cc index 3ff7c73f4..67d994f55 100644 --- a/db/db_filesnapshot.cc +++ b/db/db_filesnapshot.cc @@ -57,7 +57,9 @@ Status DBImpl::EnableFileDeletions(bool force) { } if (file_deletion_enabled) { ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled"); - PurgeObsoleteFiles(job_context); + if (job_context.HaveSomethingToDelete()) { + PurgeObsoleteFiles(job_context); + } } else { ROCKS_LOG_WARN(immutable_db_options_.info_log, "File Deletions Enable, but not really enabled. Counter: %d",