Skip to content

Commit

Permalink
fix:dbsize caculate error (OpenAtomFoundation#2494)
Browse files Browse the repository at this point in the history
* fix: dbsize caculate error
  • Loading branch information
chejinge authored and liuyuecai committed Mar 14, 2024
1 parent 2c7e409 commit 11d6df2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<storage::KeyInfo> key_infos = key_scan_info.key_infos;
if (key_infos.size() != 5) {
Expand Down

0 comments on commit 11d6df2

Please sign in to comment.