diff --git a/HISTORY.md b/HISTORY.md index c7831dd33..8c36478c3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,7 @@ ## Unreleased ### Bug Fixes * Fix a bug where range tombstone blocks in ingested files were cached incorrectly during ingestion. If range tombstones were read from those incorrectly cached blocks, the keys they covered would be exposed. +* Fix a data race that might cause crash when calling DB::GetCreationTimeOfOldestFile() by a small chance. The bug was introduced in 6.6 Release. ## 6.8.0 (02/24/2020) ### Java API Changes diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 2003cfb63..8816b9c1d 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -4541,13 +4541,21 @@ Status DBImpl::GetCreationTimeOfOldestFile(uint64_t* creation_time) { if (mutable_db_options_.max_open_files == -1) { uint64_t oldest_time = port::kMaxUint64; for (auto cfd : *versions_->GetColumnFamilySet()) { - uint64_t ctime; - cfd->current()->GetCreationTimeOfOldestFile(&ctime); - if (ctime < oldest_time) { - oldest_time = ctime; - } - if (oldest_time == 0) { - break; + if (!cfd->IsDropped()) { + uint64_t ctime; + { + SuperVersion* sv = GetAndRefSuperVersion(cfd); + Version* version = sv->current; + version->GetCreationTimeOfOldestFile(&ctime); + ReturnAndCleanupSuperVersion(cfd, sv); + } + + if (ctime < oldest_time) { + oldest_time = ctime; + } + if (oldest_time == 0) { + break; + } } } *creation_time = oldest_time;