ruthst00 commented on issue #2736: URL: https://github.com/apache/activemq/issues/2736#issuecomment-7002743603
@mattrpav, I'd like to submit a PR for this issue if that's OK with you. Here's my understanding of the problem: ### The Problem - In [`Queue.messageExpired()`](/Users/ruthes00/github/activemq/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java#L1991), the expired count is incremented before removing the message. An `IOException` during removal is only logged. - The queue-size decrement happens later in `dropMessage()`, after successful acknowledgement. A failed acknowledgement can therefore leave the queue count unchanged. - [`Message.canProcessAsExpired()`](/Users/ruthes00/github/activemq/activemq-client/src/main/java/org/apache/activemq/command/Message.java#L865) uses a one-way atomic flag to prevent repeat expiration processing. This makes a naïve “try again on the next scan” approach insufficient. - Some expiration paths also remove the message from the pending cursor before attempting store removal, so preserving access to the failed message matters. ### Recommended approach 1. Inject a one-time `IOException` during removal of a persistent expired message. 2. Reproduce the stuck queue count. 3. Make failed expiration removal recoverable, while avoiding duplicate DLQ forwarding, repeated expired-count increments, and double dequeues. 4. Verify that, after storage recovers, removal completes and queue size reaches zero. Also test repeated failures and normal expiration. Existing expiration tests and `ProxyMessageStore` test patterns provide a useful starting point. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
