Skip to content

ARTEMIS-6179 Fix deleteReference/depage deadlock - #6607

Merged
clebertsuconic merged 1 commit into
apache:mainfrom
clebertsuconic:ARTEMIS-6179
Aug 13, 2026
Merged

ARTEMIS-6179 Fix deleteReference/depage deadlock#6607
clebertsuconic merged 1 commit into
apache:mainfrom
clebertsuconic:ARTEMIS-6179

Conversation

@clebertsuconic

@clebertsuconic clebertsuconic commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/ARTEMIS-6179

QueueImpl#deleteReference() is synchronized and calls iterQueue(), which blocks on depageLock.lock(). depage() does the reverse: it takes depageLock first (via tryLock()), then needs to enter synchronized(this). Two threads acquiring the same two locks in opposite order deadlock as soon as they interleave: a removeMessage() call holds the object monitor and blocks on depageLock, while depage() holds depageLock and 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

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
clebertsuconic merged commit 00dd2dd into apache:main Aug 13, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants