diff --git a/db/db_impl_files.cc b/db/db_impl_files.cc index 3bbf94c29..e44e42318 100644 --- a/db/db_impl_files.cc +++ b/db/db_impl_files.cc @@ -368,6 +368,9 @@ void DBImpl::PurgeObsoleteFiles(const JobContext& state, bool schedule_only) { candidate_files.emplace_back( MakeTableFileName(kDumbDbName, file->fd.GetNumber()), file->fd.GetPathId()); + if (file->table_reader_handle) { + table_cache_->Release(file->table_reader_handle); + } delete file; } diff --git a/db/version_set.cc b/db/version_set.cc index 0069d86c1..ffbdd46cd 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -328,10 +328,6 @@ Version::~Version() { assert(f->refs > 0); f->refs--; if (f->refs <= 0) { - if (f->table_reader_handle) { - cfd_->table_cache()->EraseHandle(f->fd, f->table_reader_handle); - f->table_reader_handle = nullptr; - } vset_->obsolete_files_.push_back(f); } }