From 51e1c11254543b2c59aaede46b38e560f4212804 Mon Sep 17 00:00:00 2001 From: Venkatesh Radhakrishnan Date: Thu, 17 Sep 2015 10:21:34 -0700 Subject: [PATCH] Do not flag error if file to be deleted does not exist Summary: Some users have observed errors in the log file when the log file or sst file is already deleted. Test Plan: Make sure that the errors do not appear for already deleted files. Reviewers: sdong Reviewed By: sdong Subscribers: anthony, kradhakrishnan, yhchiang, rven, igor, IslamAbdelRahman, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D47115 --- db/db_impl.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 4918284bc..36d29327b 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -770,6 +770,12 @@ void DBImpl::PurgeObsoleteFiles(const JobContext& state) { "[JOB %d] Delete %s type=%d #%" PRIu64 " -- %s\n", state.job_id, fname.c_str(), type, number, file_deletion_status.ToString().c_str()); + } else if (env_->FileExists(fname).IsNotFound()) { + Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log, + "[JOB %d] Tried to delete a non-existing file %s type=%d #%" PRIu64 + " -- %s\n", + state.job_id, fname.c_str(), type, number, + file_deletion_status.ToString().c_str()); } else { Log(InfoLogLevel::ERROR_LEVEL, db_options_.info_log, "[JOB %d] Failed to delete %s type=%d #%" PRIu64 " -- %s\n", @@ -798,9 +804,16 @@ void DBImpl::PurgeObsoleteFiles(const JobContext& state) { full_path_to_delete.c_str()); Status s = env_->DeleteFile(full_path_to_delete); if (!s.ok()) { - Log(InfoLogLevel::ERROR_LEVEL, db_options_.info_log, - "[JOB %d] Delete info log file %s FAILED -- %s\n", state.job_id, - to_delete.c_str(), s.ToString().c_str()); + if (env_->FileExists(full_path_to_delete).IsNotFound()) { + Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log, + "[JOB %d] Tried to delete non-existing info log file %s FAILED " + "-- %s\n", + state.job_id, to_delete.c_str(), s.ToString().c_str()); + } else { + Log(InfoLogLevel::ERROR_LEVEL, db_options_.info_log, + "[JOB %d] Delete info log file %s FAILED -- %s\n", state.job_id, + to_delete.c_str(), s.ToString().c_str()); + } } } }