ARTEMIS-6179 Fix deleteReference/depage deadlock - #6607
Merged
Conversation
clebertsuconic
force-pushed
the
ARTEMIS-6179
branch
2 times, most recently
from
August 12, 2026 20:36
8ad7d6d to
c3ec94a
Compare
Removes synchronized from QueueImpl#deleteReference(). It calls iterQueue(), which acquires depageLock internally, while depage() acquires depageLock first and then enters a synchronized(this) block. The reversed lock order deadlocks QueueControl#removeMessage() against the paging executor whenever they race on an actively paging queue. This mirrors the fix already applied to copyReference() in ARTEMIS-5376: iterQueue() already provides its own synchronization via depageLock, so the outer synchronized on deleteReference() is redundant and unsafe. Verified with testRemoveMessageWhilstPagingAndConsuming, which reliably deadlocks without this change and passes cleanly with it.
clebertsuconic
force-pushed
the
ARTEMIS-6179
branch
from
August 13, 2026 13:18
c3ec94a to
95a0be3
Compare
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-6179
QueueImpl#deleteReference()issynchronizedand callsiterQueue(), which blocks ondepageLock.lock().depage()does the reverse: it takesdepageLockfirst (viatryLock()), then needs to entersynchronized(this). Two threads acquiring the same two locks in opposite order deadlock as soon as they interleave: aremoveMessage()call holds the object monitor and blocks ondepageLock, whiledepage()holdsdepageLockand blocks on the monitor. Neither ever releases.This is the same bug class already fixed for
copyReference()in ARTEMIS-5376 (30c8fc7).deleteReference()wasn't touched by that fix because it didn't call `it