This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new e3d068fb feat(info): move the last scan time as field to the info
keyspace section (#2775)
e3d068fb is described below
commit e3d068fbc08b04a68785e9e62186a808089b0464
Author: hulk <[email protected]>
AuthorDate: Sat Feb 8 11:05:50 2025 +0800
feat(info): move the last scan time as field to the info keyspace section
(#2775)
---
src/server/server.cc | 12 ++----------
tests/gocase/unit/info/info_test.go | 8 ++++++++
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/server/server.cc b/src/server/server.cc
index 6a4c1b55..653e3c6e 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -1251,18 +1251,10 @@ std::string Server::GetKeyspaceInfo(const std::string
&ns) {
KeyNumStats stats;
GetLatestKeyNumStats(ns, &stats);
-
- // FIXME(mwish): output still requires std::tm.
- auto last_scan_time = static_cast<time_t>(GetLastScanTime(ns));
- std::tm last_scan_tm{};
- localtime_r(&last_scan_time, &last_scan_tm);
+ auto last_dbsize_scan_timestamp = static_cast<time_t>(GetLastScanTime(ns));
string_stream << "# Keyspace\r\n";
- if (last_scan_time == 0) {
- string_stream << "# WARN: DBSIZE SCAN never performed yet\r\n";
- } else {
- string_stream << "# Last DBSIZE SCAN time: " <<
std::put_time(&last_scan_tm, "%a %b %e %H:%M:%S %Y") << "\r\n";
- }
+ string_stream << "last_dbsize_scan_timestamp:" << last_dbsize_scan_timestamp
<< "\r\n";
string_stream << "db0:keys=" << stats.n_key << ",expires=" <<
stats.n_expires << ",avg_ttl=" << stats.avg_ttl
<< ",expired=" << stats.n_expired << "\r\n";
string_stream << "sequence:" << storage->GetDB()->GetLatestSequenceNumber()
<< "\r\n";
diff --git a/tests/gocase/unit/info/info_test.go
b/tests/gocase/unit/info/info_test.go
index aace8279..56b28d35 100644
--- a/tests/gocase/unit/info/info_test.go
+++ b/tests/gocase/unit/info/info_test.go
@@ -54,6 +54,14 @@ func TestInfo(t *testing.T) {
return i
}
+ t.Run("check last dbsize scan timestamp", func(t *testing.T) {
+ require.Equal(t, "0", util.FindInfoEntry(rdb,
"last_dbsize_scan_timestamp", "keyspace"))
+ require.NoError(t, rdb.Do(ctx, "DBSIZE", "SCAN").Err())
+ require.Eventually(t, func() bool {
+ return MustAtoi(t, util.FindInfoEntry(rdb,
"last_dbsize_scan_timestamp", "keyspace")) > 0
+ }, 5*time.Second, 100*time.Millisecond)
+ })
+
t.Run("get rocksdb ops by INFO", func(t *testing.T) {
for i := 0; i < 2; i++ {
k := fmt.Sprintf("key%d", i)