Skip to content

Commit

Permalink
fix lock (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: wuxianrong <wuxianrong@360.cn>
  • Loading branch information
2 people authored and luky116 committed Mar 18, 2024
1 parent a19a54a commit ed727bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/pika_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class DB : public std::enable_shared_from_this<DB>, public pstd::noncopyable {
std::shared_mutex& GetDBLock() {
return dbs_rw_;
}
std::shared_mutex& GetDBLocks() {
return db_rwlock_;
}
void DBLock() {
dbs_rw_.lock();
}
Expand Down
2 changes: 1 addition & 1 deletion src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ed727bb

Please sign in to comment.