diff --git a/HISTORY.md b/HISTORY.md index 8e64fb3ee..b08c4005b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -31,6 +31,7 @@ Note: The next release will be major release 7.0. See https://github.com/faceboo * Fix a bug that FlushMemTable may return ok even flush not succeed. * Fixed a bug of Sync() and Fsync() not using `fcntl(F_FULLFSYNC)` on OS X and iOS. * Fixed a significant performance regression in version 6.26 when a prefix extractor is used on the read path (Seek, Get, MultiGet). (Excessive time was spent in SliceTransform::AsString().) +* Fixed a race condition in SstFileManagerImpl error recovery code that can cause a crash during process shutdown. ### New Features * Added RocksJava support for MacOS universal binary (ARM+x86) diff --git a/file/sst_file_manager_impl.cc b/file/sst_file_manager_impl.cc index f7ff03cc3..c4c411488 100644 --- a/file/sst_file_manager_impl.cc +++ b/file/sst_file_manager_impl.cc @@ -256,7 +256,7 @@ void SstFileManagerImpl::ClearError() { while (true) { MutexLock l(&mu_); - if (closing_) { + if (error_handler_list_.empty() || closing_) { return; } @@ -297,7 +297,8 @@ void SstFileManagerImpl::ClearError() { // Someone could have called CancelErrorRecovery() and the list could have // become empty, so check again here - if (s.ok() && !error_handler_list_.empty()) { + if (s.ok()) { + assert(!error_handler_list_.empty()); auto error_handler = error_handler_list_.front(); // Since we will release the mutex, set cur_instance_ to signal to the // shutdown thread, if it calls // CancelErrorRecovery() the meantime,