From 6f14d5b09e0f6498c3a30de9bc2a6f47853908cc Mon Sep 17 00:00:00 2001 From: XiaoLiang2333 <1159025475@qq.com> Date: Wed, 17 Apr 2024 05:59:05 +0800 Subject: [PATCH 1/4] Add the output data of command 'info keyspace 1' to the output of command 'info all' --- src/pika_admin.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pika_admin.cc b/src/pika_admin.cc index 9124c1a52c..f51431f95a 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -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) { @@ -1195,10 +1196,10 @@ void InfoCmd::InfoKeyspace(std::string& info) { tmp_stream << "# Keyspace" << "\r\n"; - if (argv_.size() == 3) { // command => `info keyspace 1` + if (argv_.size() == 3 || strcasecmp(argv_[1].data(),"all")==0){ // command => `info keyspace 1` or `info all` tmp_stream << "# Start async statistics" << "\r\n"; - } else { // command => `info keyspace` or `info` + } else { // command => `info keyspace` tmp_stream << "# Use \"info keyspace 1\" do async statistics" << "\r\n"; } From e0052a0b119602910201c28059639388fabde4a6 Mon Sep 17 00:00:00 2001 From: XiaoLiang2333 <1159025475@qq.com> Date: Thu, 18 Apr 2024 03:17:51 +0800 Subject: [PATCH 2/4] fix bugs --- src/pika_admin.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/pika_admin.cc b/src/pika_admin.cc index f51431f95a..60d4451439 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -811,6 +811,7 @@ void InfoCmd::DoInitial() { info_section_ = kInfoKeyspace; if (argc == 2) { LogCommand(); + return; } // info keyspace [ 0 | 1 | off ] @@ -1195,15 +1196,27 @@ void InfoCmd::InfoKeyspace(std::string& info) { std::stringstream tmp_stream; tmp_stream << "# Keyspace" << "\r\n"; + if (argv_.size()> 1 && strcasecmp(argv_[1].data(), kAllSection.data()) == 0) { + // Command=>"info all" + tmp_stream << "# Start async statistics\r\n"; + } else if (argv_.size() > 2 && strcasecmp(argv_[1].data(), kKeyspaceSection.data()) == 0) { - if (argv_.size() == 3 || strcasecmp(argv_[1].data(),"all")==0){ // command => `info keyspace 1` or `info all` + if (argv_.size() == 3) { + tmp_stream << "# Start async statistics\r\n"; // Command=>"info keyspace 1|0" + } else { + tmp_stream << "# Use \"info keyspace 1\" to do async statistics\r\n"; // Command=>"info keyspace" + } + } else { + tmp_stream << "# Use \"info keyspace 1\" to do async statistics\r\n"; // Command=>"info" + } + /**if (argv_.size() == 3){ // command => `info keyspace 1` or `info all` tmp_stream << "# Start async statistics" << "\r\n"; } else { // command => `info keyspace` tmp_stream << "# Use \"info keyspace 1\" 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()) { @@ -1226,7 +1239,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 @@ -1240,7 +1253,6 @@ void InfoCmd::InfoKeyspace(std::string& info) { } } info.append(tmp_stream.str()); - if (rescan_) { g_pika_server->DoSameThingSpecificDB(keyspace_scan_dbs_, {TaskType::kStartKeyScan}); } From d92f6eb2dd4c13b46e9dd2962a671c3f32b1dec6 Mon Sep 17 00:00:00 2001 From: DawnBeams <118454556+XiaoLiang2333@users.noreply.github.com> Date: Sun, 28 Apr 2024 12:43:03 +0800 Subject: [PATCH 3/4] Remove obsolete code Remove obsolete code --- src/pika_admin.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/pika_admin.cc b/src/pika_admin.cc index 60d4451439..b2e7d1d1d1 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -1209,14 +1209,6 @@ void InfoCmd::InfoKeyspace(std::string& info) { } else { tmp_stream << "# Use \"info keyspace 1\" to do async statistics\r\n"; // Command=>"info" } - /**if (argv_.size() == 3){ // command => `info keyspace 1` or `info all` - tmp_stream << "# Start async statistics" - << "\r\n"; - } else { // command => `info keyspace` - tmp_stream << "# Use \"info keyspace 1\" 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()) { From ca0856edda6ee3aec2a2be1bbada432192424b13 Mon Sep 17 00:00:00 2001 From: DawnBeams <118454556+XiaoLiang2333@users.noreply.github.com> Date: Mon, 29 Apr 2024 00:39:36 +0800 Subject: [PATCH 4/4] Update --- src/pika_admin.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/pika_admin.cc b/src/pika_admin.cc index b2e7d1d1d1..dcc51a2560 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -1196,18 +1196,12 @@ void InfoCmd::InfoKeyspace(std::string& info) { std::stringstream tmp_stream; tmp_stream << "# Keyspace" << "\r\n"; - if (argv_.size()> 1 && strcasecmp(argv_[1].data(), kAllSection.data()) == 0) { - // Command=>"info all" + if (argv_.size() > 1 && strcasecmp(argv_[1].data(), kAllSection.data()) == 0) { tmp_stream << "# Start async statistics\r\n"; - } else if (argv_.size() > 2 && strcasecmp(argv_[1].data(), kKeyspaceSection.data()) == 0) { - - if (argv_.size() == 3) { - tmp_stream << "# Start async statistics\r\n"; // Command=>"info keyspace 1|0" - } else { - tmp_stream << "# Use \"info keyspace 1\" to do async statistics\r\n"; // Command=>"info keyspace" - } + } 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"; // Command=>"info" + 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_) {