Skip to content

Per-vhost message_stats over-counts published messages (sums per-queue counters) #2092

Description

@jage

Describe the bug

/api/vhosts/:name builds message_stats by summing each queue's counters
(vhost.message_details, vhost.cr:277), so a publish routed to N queues counts as N. The vhost's
own atomic counter holds the true client-publish count and is exposed by /api/overview and
detailed_vhost_messages_published_total, so the surfaces disagree.

Describe your setup

Current main, bin/lavinmq --build-info: 2.8.0-85-g279028c4, default config.

How to reproduce

curl -u guest:guest -XPUT localhost:15672/api/vhosts/t
curl -u guest:guest -H 'content-type: application/json' -XPUT -d '{"type":"fanout","durable":true}' localhost:15672/api/exchanges/t/fx
for q in q1 q2 q3; do
  curl -u guest:guest -H 'content-type: application/json' -XPUT -d '{"durable":true}' localhost:15672/api/queues/t/$q
  curl -u guest:guest -H 'content-type: application/json' -XPOST -d '{"routing_key":""}' localhost:15672/api/bindings/t/e/fx/q/$q
done
curl -u guest:guest -H 'content-type: application/json' -XPOST -d '{"routing_key":"","payload":"x","payload_encoding":"string","properties":{}}' localhost:15672/api/exchanges/t/fx/publish
curl -u guest:guest localhost:15672/api/vhosts/t                  # message_stats.publish = 3
curl -u guest:guest -H 'x-vhost: t' localhost:15672/api/overview  # message_stats.publish = 1

Expected behavior

One client publish counts as one publish, and /api/vhosts/:name agrees with /api/overview.
(Fix: source message_stats from the vhost atomics.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions