Repository navigation
ARTEMIS-6154 Broker should never report a negative message count - #6958
Open
Komalvighe wants to merge 1 commit into
Open
Komalvighe wants to merge 1 commit into
Komalvighe wants to merge 1 commit into
Conversation
Queue message counts are aggregated from several independently maintained metrics. When a message is accounted as removed more than once -- for example a queue purge racing with acknowledgements on a paged queue -- the page subscription counter drifts below zero and the negative value is surfaced verbatim through the JMX messageCount attribute and through listQueues in the web console. Floor the page subscription count and the aggregated queue counts at zero. The raw values are still logged at debug level in QueueImpl#getMessageCount so the underlying drift stays diagnosable. This is a defensive fix for the reported symptom; it does not address the root cause of the counter drift. Komal Vighe
Contributor
|
I'm worried that this is just masking the actual issues with paging and/or counters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/ARTEMIS-6154
Problem
QueueImpl#getMessageCount()sums four independently maintained metrics. On apaged queue the last term is
PageSubscriptionImpl#getMessageCount(), whichreturns the persisted
PageSubscriptionCountervalue. That counter drifts belowzero when a message is accounted as removed more than once -- the reporter
reproduced this by purging a queue while a consumer was acknowledging, so
messagesAcked + messagesKilledexceededmessagesAdded.Nothing floors the result, so the negative value is reported verbatim by:
QueueControlImpl#getMessageCount()(the JMXmessageCountattribute)QueueView/listQueues, which is what the web console rendersChange
PageSubscriptionImpl#getMessageCount()floors at zero, matching the guardgetPersistentSize()directly below it already has.QueueImpl#getMessageCount()/#getDurableMessageCount()floor theaggregate, covering drift in the non-paged metrics as well.
LastValueQueue#getMessageCount()floors too -- it subtracts the deliveringcount after
super, so it can still go negative on its own.Queue#getMessageCount()javadoc now states the value is never negative.Clamping at the subscription as well as the aggregate keeps a partially-valid
count accurate: with
pending=50andcounter=-100the result is 50, not 0.The raw computed value is still emitted by the existing debug log in
QueueImpl#getMessageCount, so the underlying drift remains diagnosable.Scope
This is a defensive fix for the reported symptom, not a fix for the counter
drift itself. One related symptom is also not fixed here: the reporter notes
the messages become invisible in the console, which comes from
QueueControlImpl#browse()bounding its iteration withMath.min(page * pageSize, queue.getMessageCount()). With a broken counter thatbound is wrong either way. Happy to follow up on that under a separate JIRA if
reviewers agree it belongs there.
Testing
NegativeMessageCountTestdrives the page subscription counter negative on apaging queue and asserts the reported counts are zero.