Repository navigation
ARTEMIS-6358 Fix race when sending concurrent retained messages - #6879
Conversation
|
I'm confused by the title referencing lost messages. Typically a "lost" message is one where the client has every confidence that the message was actually published successfully when, in fact, it wasn't. If a publisher gets no It seems that a commit message like "fix race when sending concurrent retained messages" would be more accurate. |
|
You're right, "lost" isn't accurate here — the client never gets a PUBACK for the failed publish, so on QoS 1 it just retries and the retained message lands. The real defect is the race itself: two connections publishing a retained message to the same new topic at once both see |
When two connections publish a retained message to the same new topic at once, both see locateQueue return null and both call createQueue for the retain queue; the loser gets an exception and its publish fails. Pass ignoreIfExists=true so a connection that loses the race uses the queue the winner created instead of failing.
85713f9 to
ff34fed
Compare
|
Thanks, @grepjava! |
MQTTRetainMessageManager.handleRetainedMessagelooked up the topic's retain queue and created it when missing withcreateQueue(QueueConfiguration). Two connections publishing the first retained messages to a topic at the same time could both find no queue, and the secondcreateQueuethrewActiveMQQueueExistsException(AMQ229019). The publish was rolled back and the client got no PUBACK: the message reached neither the subscribers nor the retain queue.The queue is now created with
ignoreIfExists, so a connection that loses the race uses the queue the other one created.MQTTTest.testFirstRetainedMessagesPublishedAtOncehas 16 clients publish a retained QoS 1 message to a new topic at once, for 10 topics, and checks that every publish is acknowledged and a new subscriber gets one retained message. It fails without the fix.https://issues.apache.org/jira/browse/ARTEMIS-6358