Skip to content

Prevent cursor from using more than 100% temp store#2165

Merged
cshannon merged 2 commits into
apache:mainfrom
cshannon:limit-file-pending-disk-usage
Jul 2, 2026
Merged

Prevent cursor from using more than 100% temp store#2165
cshannon merged 2 commits into
apache:mainfrom
cshannon:limit-file-pending-disk-usage

Conversation

@cshannon

Copy link
Copy Markdown
Contributor

This fixes a bug in FilePendingMessageCursor that could cause the temporary store to exceed 100% usage. The cursor now properly checks the temporary usage limits when writing messages from memory to the temporary store. If the store is full, messages are now discarded and a discarded advisory will be fired (if enabled) and the messages will be DLQ'd if the processNonPersistent flag is true. This commit also fixes an issue with Topic subs possibly sending expired messages to the DLQ twice which was noticed while working on this fix.

While not a common scenario, previously it was possible to blow past the limits for the temporary store because FilePendingMessageCursor did not check if usage was 100%. This could happen if there was a small temporary store configured, or just simply a lot of destinations using temporary usage. In the worst case scenario this could mean filling up a partition and causing an IO exception and broker crash, best case it would still be bad because it uses up disk space meant for persistent messaging.

This fixes a bug in FilePendingMessageCursor that could cause the
temporary store to exceed 100% usage. The cursor now properly checks the
temporary usage limits when writing messages from memory to the
temporary store. If the store is full, messages are now discarded and
a discarded advisory will be fired (if enabled) and the messages will be
DLQ'd if the processNonPersistent flag is true. This commit also fixes
an issue with Topic subs possibly sending expired messages to the DLQ
twice which was noticed while working on this fix.

private void discardMessage(MessageReference reference) {
try {
LOG.debug("Discarding message {}", reference);

@mattrpav mattrpav Jul 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think the log should say why it is discarding in the message -- temp space full, temp space disabled, expired, etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattrpav - I updated the log message

@cshannon cshannon requested a review from mattrpav July 2, 2026 12:40

@mattrpav mattrpav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cshannon cshannon merged commit 4c34a49 into apache:main Jul 2, 2026
9 of 10 checks passed
@cshannon cshannon deleted the limit-file-pending-disk-usage branch July 2, 2026 14:14
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Apache ActiveMQ v6.3.0 Jul 2, 2026
cshannon added a commit that referenced this pull request Jul 2, 2026
This fixes a bug in FilePendingMessageCursor that could cause the
temporary store to exceed 100% usage. The cursor now properly checks the
temporary usage limits when writing messages from memory to the
temporary store. If the store is full, messages are now discarded and
a discarded advisory will be fired (if enabled) and the messages will be
DLQ'd if the processNonPersistent flag is true. This commit also fixes
an issue with Topic subs possibly sending expired messages to the DLQ
twice which was noticed while working on this fix.

(cherry picked from commit 4c34a49)
cshannon added a commit that referenced this pull request Jul 2, 2026
This fixes a bug in FilePendingMessageCursor that could cause the
temporary store to exceed 100% usage. The cursor now properly checks the
temporary usage limits when writing messages from memory to the
temporary store. If the store is full, messages are now discarded and
a discarded advisory will be fired (if enabled) and the messages will be
DLQ'd if the processNonPersistent flag is true. This commit also fixes
an issue with Topic subs possibly sending expired messages to the DLQ
twice which was noticed while working on this fix.

(cherry picked from commit 4c34a49)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants