diff --git a/HISTORY.md b/HISTORY.md index a38f5ad54..0a976033e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -16,6 +16,7 @@ * Fix race conditions in `GenericRateLimiter`. * Fix a bug in `FIFOCompactionPicker::PickTTLCompaction` where total_size calculating might cause underflow * Fix data race bug in hash linked list memtable. With this bug, read request might temporarily miss an old record in the memtable in a race condition to the hash bucket. +* Fix a bug that `best_efforts_recovery` may fail to open the db with mmap read. ### Behavior Change * Added checksum handshake during the copying of decompressed WAL fragment. This together with #9875, #10037, #10212, #10114 and #10319 provides end-to-end integrity protection for write batch during recovery. diff --git a/db/db_impl/db_impl_open.cc b/db/db_impl/db_impl_open.cc index 47d558e57..afeb8de50 100644 --- a/db/db_impl/db_impl_open.cc +++ b/db/db_impl/db_impl_open.cc @@ -441,11 +441,14 @@ Status DBImpl::Recover( uint64_t number = 0; FileType type = kWalFile; // initialize if (ParseFileName(file, &number, &type) && type == kDescriptorFile) { - // Found MANIFEST (descriptor log), thus best-efforts recovery does - // not have to treat the db as empty. - s = Status::OK(); - manifest_path = dbname_ + "/" + file; - break; + uint64_t bytes; + s = env_->GetFileSize(DescriptorFileName(dbname_, number), &bytes); + if (s.ok() && bytes != 0) { + // Found non-empty MANIFEST (descriptor log), thus best-efforts + // recovery does not have to treat the db as empty. + manifest_path = dbname_ + "/" + file; + break; + } } } }