Skip to content

ARTEMIS-6366 Two transactions that send the same duplicate id before either commits both deliver the message - #6904

Open
grepjava wants to merge 2 commits into
apache:mainfrom
grepjava:ARTEMIS-6366
Open

grepjava wants to merge 2 commits into
apache:mainfrom
grepjava:ARTEMIS-6366

Conversation

@grepjava

Copy link
Copy Markdown
Contributor

For a send in a client transaction, PostOfficeImpl.checkNotBridgeDuplicateID checks cache.contains and addToCache(id, tx, false) only registers an AddDuplicateIDOperation that adds the id after the commit is stored, so that a client resending a failed transaction is not rejected. Nothing checked the id again at the commit: two transactions that sent the same id before either committed both committed, and the message was delivered twice.

That operation now checks the id against the cache again in beforePrepare / beforeCommit, and holds it in the in-flight count from then on (released once it takes its slot after the commit, or on rollback). If another transaction committed it first, TransactionImpl rolls the transaction back, as one marked rollback-only, and the commit or prepare fails with ActiveMQDuplicateIdException. An open transaction still holds nothing, so a resent transaction is accepted. A prepared transaction recovered after a restart holds its ids again (load).

This builds on #6883 (ARTEMIS-6362), which adds the in-flight count; until that is merged this PR also shows its commit.

DuplicateDetectionTest.testOverlappingTransactionsSendTheIdOnce sends the same id from two sessions, each in a transaction, commits the first and expects the second commit to fail and one message to arrive. It fails without the fix. testXADuplicateDetection3 said the second branch "Should NOT be able to resend it", but it could, and the test discarded the first receive; it now expects the prepare to fail with DUPLICATE_ID_REJECTED (as testXADuplicateDetection4 does) and no message.

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

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.

1 participant