You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by hu...@apache.org on 2025/09/28 12:55:11 UTC

(kvrocks) branch unstable updated: fix(storage): data race when closing the DB (#3203)

This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 938e84ad1 fix(storage): data race when closing the DB (#3203)
938e84ad1 is described below

commit 938e84ad13da73a1478c34a26659b9a6ffe1d7b3
Author: hulk <hu...@gmail.com>
AuthorDate: Sun Sep 28 20:55:07 2025 +0800

    fix(storage): data race when closing the DB (#3203)
    
    This fixes the issue mentioned in
    https://github.com/apache/kvrocks/pull/3201#issuecomment-3342833450.
    
    Co-authored-by: Twice <tw...@gmail.com>
---
 src/storage/storage.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/storage/storage.cc b/src/storage/storage.cc
index 3fb83de52..aa4dbb1a1 100644
--- a/src/storage/storage.cc
+++ b/src/storage/storage.cc
@@ -103,6 +103,9 @@ void Storage::CloseDB() {
 
   db_closing_ = true;
   db_->SyncWAL();
+  // Make sure all background work is stopped to avoid the data race
+  // between background threads and the column family handle destruction.
+  rocksdb::CancelAllBackgroundWork(db_.get(), true);
   for (auto handle : cf_handles_) db_->DestroyColumnFamilyHandle(handle);
   db_->Close();
   db_ = nullptr;