@@ -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