From 11a4d5c33ba22e1fc5482a825b1c03e047b04f17 Mon Sep 17 00:00:00 2001 From: wuxianrong Date: Fri, 15 Mar 2024 17:03:03 +0800 Subject: [PATCH] fix lock --- include/pika_db.h | 3 +++ src/pika_admin.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/pika_db.h b/include/pika_db.h index 8280b6bf38..2b96dc7079 100644 --- a/include/pika_db.h +++ b/include/pika_db.h @@ -101,6 +101,9 @@ class DB : public std::enable_shared_from_this, public pstd::noncopyable { std::shared_mutex& GetDBLock() { return dbs_rw_; } + std::shared_mutex& GetDBLocks() { + return db_rwlock_; + } void DBLock() { dbs_rw_.lock(); } diff --git a/src/pika_admin.cc b/src/pika_admin.cc index e7741b4241..6025498652 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -709,7 +709,7 @@ void FlushdbCmd::Execute() { if (db_->IsKeyScaning()) { res_.SetRes(CmdRes::kErrOther, "The keyscan operation is executing, Try again later"); } else { - std::lock_guard l_prw(db_->GetDBLock()); + std::lock_guard l_prw(db_->GetDBLocks()); std::lock_guard s_prw(g_pika_rm->GetDBLock()); FlushAllDBsWithoutLock(); res_.SetRes(CmdRes::kOk);