From 9da88a8321239b71487fc63109a961fce423ba26 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Tue, 30 Oct 2018 10:32:05 -0700 Subject: [PATCH] Remove info logging in db mutex inside EnableFileDeletions() (#4604) Summary: EnableFileDeletions() does info logging inside db mutex. This is not recommended in the code base, since there could be I/O involved. Move this outside the DB mutex. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4604 Differential Revision: D12834432 Pulled By: siying fbshipit-source-id: ffe5c2626fcfdb4c54a661a3c3b0bc95054816cf --- db/db_filesnapshot.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/db/db_filesnapshot.cc b/db/db_filesnapshot.cc index 3725ff9549..e956b8a8a0 100644 --- a/db/db_filesnapshot.cc +++ b/db/db_filesnapshot.cc @@ -44,7 +44,7 @@ Status DBImpl::EnableFileDeletions(bool force) { // Job id == 0 means that this is not our background process, but rather // user thread JobContext job_context(0); - bool should_purge_files = false; + bool file_deletion_enabled = false; { InstrumentedMutexLock l(&mutex_); if (force) { @@ -54,19 +54,18 @@ Status DBImpl::EnableFileDeletions(bool force) { --disable_delete_obsolete_files_; } if (disable_delete_obsolete_files_ == 0) { - ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled"); - should_purge_files = true; + file_deletion_enabled = true; FindObsoleteFiles(&job_context, true); bg_cv_.SignalAll(); - } else { - ROCKS_LOG_WARN( - immutable_db_options_.info_log, - "File Deletions Enable, but not really enabled. Counter: %d", - disable_delete_obsolete_files_); } } - if (should_purge_files) { + if (file_deletion_enabled) { + ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled"); PurgeObsoleteFiles(job_context); + } else { + ROCKS_LOG_WARN(immutable_db_options_.info_log, + "File Deletions Enable, but not really enabled. Counter: %d", + disable_delete_obsolete_files_); } job_context.Clean(); LogFlush(immutable_db_options_.info_log);