Skip to content

Commit

Permalink
fix:Add the output data of command 'info keyspace 0' to the output of…
Browse files Browse the repository at this point in the history
… com… (OpenAtomFoundation#2603)

* Add the output data of command 'info keyspace 1' to the output of command 'info all'
  • Loading branch information
XiaoLiang2333 authored and chenbt-hz committed Jun 3, 2024
1 parent b043f07 commit 665a205
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ void InfoCmd::DoInitial() {

if (strcasecmp(argv_[1].data(), kAllSection.data()) == 0) {
info_section_ = kInfoAll;
keyspace_scan_dbs_ = g_pika_server->GetAllDBName();
} else if (strcasecmp(argv_[1].data(), kServerSection.data()) == 0) {
info_section_ = kInfoServer;
} else if (strcasecmp(argv_[1].data(), kClientsSection.data()) == 0) {
Expand All @@ -810,6 +811,7 @@ void InfoCmd::DoInitial() {
info_section_ = kInfoKeyspace;
if (argc == 2) {
LogCommand();

return;
}
// info keyspace [ 0 | 1 | off ]
Expand Down Expand Up @@ -1194,15 +1196,13 @@ void InfoCmd::InfoKeyspace(std::string& info) {
std::stringstream tmp_stream;
tmp_stream << "# Keyspace"
<< "\r\n";

if (argv_.size() == 3) { // command => `info keyspace 1`
tmp_stream << "# Start async statistics"
<< "\r\n";
} else { // command => `info keyspace` or `info`
tmp_stream << "# Use \"info keyspace 1\" do async statistics"
<< "\r\n";
if (argv_.size() > 1 && strcasecmp(argv_[1].data(), kAllSection.data()) == 0) {
tmp_stream << "# Start async statistics\r\n";
} else if (argv_.size() == 3 && strcasecmp(argv_[1].data(), kKeyspaceSection.data()) == 0) {
tmp_stream << "# Start async statistics\r\n";
} else {
tmp_stream << "# Use \"info keyspace 1\" to do async statistics\r\n";
}

std::shared_lock rwl(g_pika_server->dbs_rw_);
for (const auto& db_item : g_pika_server->dbs_) {
if (keyspace_scan_dbs_.find(db_item.first) != keyspace_scan_dbs_.end()) {
Expand All @@ -1225,7 +1225,7 @@ void InfoCmd::InfoKeyspace(std::string& info) {
tmp_stream << "# Duration: " << std::to_string(duration) + "s"
<< "\r\n";
}

tmp_stream << db_name << " Strings_keys=" << key_infos[0].keys << ", expires=" << key_infos[0].expires
<< ", invalid_keys=" << key_infos[0].invaild_keys << "\r\n";
tmp_stream << db_name << " Hashes_keys=" << key_infos[1].keys << ", expires=" << key_infos[1].expires
Expand All @@ -1239,7 +1239,6 @@ void InfoCmd::InfoKeyspace(std::string& info) {
}
}
info.append(tmp_stream.str());

if (rescan_) {
g_pika_server->DoSameThingSpecificDB(keyspace_scan_dbs_, {TaskType::kStartKeyScan});
}
Expand Down

0 comments on commit 665a205

Please sign in to comment.