Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:Add the output data of command 'info keyspace 0' to the output of com… #2603

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading