From 11d6df2851fa5501aa577ecb2a1d2684af681bc9 Mon Sep 17 00:00:00 2001 From: chejinge <945997690@qq.com> Date: Wed, 13 Mar 2024 10:51:02 +0800 Subject: [PATCH] fix:dbsize caculate error (#2494) * fix: dbsize caculate error --- src/pika_admin.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pika_admin.cc b/src/pika_admin.cc index b7476840b7..5fd981b55b 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -2711,6 +2711,20 @@ void DbsizeCmd::Do() { if (!dbs) { res_.SetRes(CmdRes::kInvalidDB); } else { + if (g_pika_conf->slotmigrate()){ + int64_t dbsize = 0; + for (int i = 0; i < g_pika_conf->default_slot_num(); ++i){ + int32_t card = 0; + rocksdb::Status s = dbs->storage()->SCard(SlotKeyPrefix+std::to_string(i), &card); + if (s.ok() && card >= 0) { + dbsize += card; + } else { + res_.SetRes(CmdRes::kErrOther, "Get dbsize error"); + return; + } + } + res_.AppendInteger(dbsize); + } KeyScanInfo key_scan_info = dbs->GetKeyScanInfo(); std::vector key_infos = key_scan_info.key_infos; if (key_infos.size() != 5) {