ARTEMIS-6241 mitigate potential races - #6688
Open
jbertram wants to merge 1 commit into
Open
Conversation
jbertram
force-pushed
the
ARTEMIS-6241
branch
2 times, most recently
from
September 10, 2026 17:29
09a7292 to
c602e17
Compare
Unify locking so sendToQueue() and the PUBACK/PUBREC/PUBREL/PUBCOMP handlers all synchronize on the same monitor (i.e. this), and move the duplicate-packet-ID check into sendToQueue() itself so the check and the cache mutation happen atomically under that lock. Also removes the now-unused lock field. Refactor a few methods out of sendToQueue() to increase readability. Add in-memory cache values instantly vs. using Transaction#afterStore to avoid races with other packet handling that needs to read in-memory values. Lastly, move outgoing protocol logging closer to where the packet is put on the wire. Static analysis must suffice to justify these changes as no test was able to induce the race(s).
jbertram
force-pushed
the
ARTEMIS-6241
branch
from
September 10, 2026 17:34
c602e17 to
29b74ae
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.
Unify locking so
sendToQueue()and thePUBACK/PUBREC/PUBREL/PUBCOMPhandlers all synchronize on the same monitor (i.e. this), and move the duplicate-packet-ID check intosendToQueue()itself so the check and the cache mutation happen atomically under that lock. Also removes the now-unused lock field.Refactor a few methods out of
sendToQueue()to increase readability.Add in-memory cache values instantly vs. using
Transaction#afterStoreto avoid races with other packet handling that needs to read in-memory values.Lastly, move outgoing protocol logging closer to where the packet is put on the wire.
Static analysis must suffice to justify these changes as no test was able to induce the race(s).