From be72e2e82529bfffb5b2c6d85831877352e0a59f Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Wed, 30 Aug 2023 14:20:58 +0300 Subject: [PATCH] fix: Add db id to client list attributes Fixes #1767 Signed-off-by: Roman Gershman --- src/facade/dragonfly_connection.cc | 4 +--- src/server/main_service.cc | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/facade/dragonfly_connection.cc b/src/facade/dragonfly_connection.cc index f952501670ed..772932d7f740 100644 --- a/src/facade/dragonfly_connection.cc +++ b/src/facade/dragonfly_connection.cc @@ -391,9 +391,7 @@ string Connection::GetClientInfo(unsigned thread_id) const { if (cc_) { string cc_info = service_->GetContextInfo(cc_.get()); - if (!cc_info.empty()) { - absl::StrAppend(&res, " ", cc_info); - } + absl::StrAppend(&res, " ", cc_info); } return res; diff --git a/src/server/main_service.cc b/src/server/main_service.cc index cdee899a9461..2925b50870fb 100644 --- a/src/server/main_service.cc +++ b/src/server/main_service.cc @@ -2045,6 +2045,8 @@ string Service::GetContextInfo(facade::ConnectionContext* cntx) { unsigned index = 0; ConnectionContext* server_cntx = static_cast(cntx); + string res = absl::StrCat("db=", server_cntx->db_index()); + if (server_cntx->async_dispatch) buf[index++] = 'a'; @@ -2057,7 +2059,10 @@ string Service::GetContextInfo(facade::ConnectionContext* cntx) { if (server_cntx->conn_state.is_blocking) buf[index++] = 'b'; - return index ? absl::StrCat("flags:", buf) : string(); + if (index) { + absl::StrAppend(&res, " flags=", buf); + } + return res; } using ServiceFunc = void (Service::*)(CmdArgList, ConnectionContext* cntx);