diff --git a/db/db_impl.cc b/db/db_impl.cc index 6a13fbbc1..f0bba0ae6 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2047,8 +2047,7 @@ Status DBImpl::DeleteFile(std::string name) { name.c_str()); return Status::NotSupported("Delete only supported for archived logs"); } - status = - env_->DeleteFile(immutable_db_options_.wal_dir + "/" + name.c_str()); + status = wal_manager_.DeleteFile(name, number); if (!status.ok()) { ROCKS_LOG_ERROR(immutable_db_options_.info_log, "DeleteFile %s failed -- %s.\n", name.c_str(), diff --git a/db/wal_manager.cc b/db/wal_manager.cc index 235b74987..770470f6e 100644 --- a/db/wal_manager.cc +++ b/db/wal_manager.cc @@ -39,6 +39,15 @@ namespace rocksdb { #ifndef ROCKSDB_LITE +Status WalManager::DeleteFile(const std::string& fname, uint64_t number) { + auto s = env_->DeleteFile(db_options_.wal_dir + "/" + fname); + if (s.ok()) { + MutexLock l(&read_first_record_cache_mutex_); + read_first_record_cache_.erase(number); + } + return s; +} + Status WalManager::GetSortedWalFiles(VectorLogPtr& files) { // First get sorted files in db dir, then get sorted files from archived // dir, to avoid a race condition where a log file is moved to archived diff --git a/db/wal_manager.h b/db/wal_manager.h index 09a8d49c7..6caf1640c 100644 --- a/db/wal_manager.h +++ b/db/wal_manager.h @@ -49,6 +49,8 @@ class WalManager { void ArchiveWALFile(const std::string& fname, uint64_t number); + Status DeleteFile(const std::string& fname, uint64_t number); + Status TEST_ReadFirstRecord(const WalFileType type, const uint64_t number, SequenceNumber* sequence) { return ReadFirstRecord(type, number, sequence);