From 9c58cf5717c7bf7c28ee5f91843261c3629b52d5 Mon Sep 17 00:00:00 2001 From: cheniujh <41671101+cheniujh@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:54:02 +0800 Subject: [PATCH] draft fix of bgsave's inconsistent problem (#2818) Co-authored-by: cheniujh <1271435567@qq.com> --- src/pika_command.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/pika_command.cc b/src/pika_command.cc index d3f917d53f..dea2dec475 100644 --- a/src/pika_command.cc +++ b/src/pika_command.cc @@ -875,27 +875,26 @@ void Cmd::InternalProcessCommand(const HintKeys& hint_keys) { if (g_pika_conf->slowlog_slower_than() >= 0) { start_us = pstd::NowMicros(); } + + if (!IsSuspend()) { + db_->DBLockShared(); + } + DoCommand(hint_keys); if (g_pika_conf->slowlog_slower_than() >= 0) { do_duration_ += pstd::NowMicros() - start_us; } - DoBinlog(); + if (!IsSuspend()) { + db_->DBUnlockShared(); + } if (is_write()) { record_lock.Unlock(current_key()); } } void Cmd::DoCommand(const HintKeys& hint_keys) { - if (!IsSuspend()) { - db_->DBLockShared(); - } - DEFER { - if (!IsSuspend()) { - db_->DBUnlockShared(); - } - }; if (IsNeedCacheDo() && PIKA_CACHE_NONE != g_pika_conf->cache_mode() && db_->cache()->CacheStatus() == PIKA_CACHE_STATUS_OK) {