diff --git a/db/db_impl.cc b/db/db_impl.cc index 2732f0db5..404d51da0 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3131,20 +3131,19 @@ Status DBImpl::IngestExternalFile( &need_flush); if (status.ok() && need_flush) { if (immutable_db_options_.atomic_flush) { - mutex_.Unlock(); autovector cfds; SelectColumnFamiliesForAtomicFlush(&cfds); + mutex_.Unlock(); status = AtomicFlushMemTables(cfds, FlushOptions(), FlushReason::kExternalFileIngestion, true /* writes_stopped */); - mutex_.Lock(); } else { mutex_.Unlock(); status = FlushMemTable(cfd, FlushOptions(), FlushReason::kExternalFileIngestion, true /* writes_stopped */); - mutex_.Lock(); } + mutex_.Lock(); } } diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc index d584f2077..fa0b91877 100644 --- a/db/db_impl_compaction_flush.cc +++ b/db/db_impl_compaction_flush.cc @@ -588,7 +588,9 @@ Status DBImpl::CompactRange(const CompactRangeOptions& options, fo.allow_write_stall = options.allow_write_stall; if (immutable_db_options_.atomic_flush) { autovector cfds; + mutex_.Lock(); SelectColumnFamiliesForAtomicFlush(&cfds); + mutex_.Unlock(); s = AtomicFlushMemTables(cfds, fo, FlushReason::kManualCompaction, false /* writes_stopped */); } else {