@@ -3270,7 +3270,7 @@ string ServerFamily::FormatInfoMetrics(const Metrics& m, std::string_view sectio
32703270 if (show) {
32713271 size_t total = stats.events .hits + stats.events .misses ;
32723272 double hit_ratio =
3273- (total > 0 ) ? static_cast <double >(stats.events .hits ) / (total)* 100.0 : 0.0 ;
3273+ (total > 0 ) ? static_cast <double >(stats.events .hits ) / (total) * 100.0 : 0.0 ;
32743274 string val = StrCat (" keys=" , stats.key_count , " ,expires=" , stats.expire_count ,
32753275 " ,hits=" , stats.events .hits , " ,misses=" , stats.events .misses ,
32763276 " ,hit_ratio=" , absl::StrFormat (" %.2f" , hit_ratio),
@@ -3331,7 +3331,7 @@ string ServerFamily::FormatInfoMetrics(const Metrics& m, std::string_view sectio
33313331
33323332void ServerFamily::Info (CmdArgList args, const CommandContext& cmd_cntx) {
33333333 std::vector<std::string> sections;
3334- auto need_metrics{false }; // Save time - do not fetch metrics if we don't need them.
3334+ bool need_metrics{false }; // Save time - do not fetch metrics if we don't need them.
33353335 Metrics metrics;
33363336
33373337 sections.reserve (args.size ());
@@ -3340,18 +3340,19 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) {
33403340 const auto & section = sections.back ();
33413341 if (!need_metrics && (section != " SERVER" ) && (section != " REPLICATION" )) {
33423342 need_metrics = true ;
3343- metrics = GetMetrics (cmd_cntx.conn_cntx ->ns );
33443343 }
33453344 }
33463345
3347- if (!need_metrics && !IsMaster ()) {
3346+ if (need_metrics || sections.empty ()) {
3347+ metrics = GetMetrics (cmd_cntx.conn_cntx ->ns );
3348+ } else if (!IsMaster ()) {
33483349 metrics.replica_side_info = GetReplicaSummary ();
33493350 }
33503351
33513352 std::string info;
33523353 // For multiple requested sections, invalid section names are ignored (not included in the
33533354 // output). The command does not abort or return an error if some sections are invalid. This
3354- // matches Redis behavior.
3355+ // matches Valkey behavior.
33553356 if (sections.empty ()) { // No sections: default to all sections.
33563357 info = FormatInfoMetrics (metrics, " " , cmd_cntx.conn_cntx ->conn ()->IsPrivileged ());
33573358 } else if (sections.size () == 1 ) { // Single section
0 commit comments