Skip to content

Bug: Queue size incorrect when IOException thrown #2736

Open

Description

@mattrpav

During message expiration, an IOException may throw and never retry

Activity

  1. ruthst00 commented on Nov 19, 2026

    @ruthst00

    @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(), 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() 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.

  2. mattrpav commented on Nov 19, 2026

    @mattrpav
    ContributorAuthor

    @ruthst00 I already have a PR for this one in review. It is very nuanced, and would not suggest this one for a new contributor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions