mattrpav commented on code in PR #2584:
URL: https://github.com/apache/activemq/pull/2584#discussion_r4083175576


##########
activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java:
##########
@@ -526,6 +526,28 @@ public void removeAsyncMessage(ConnectionContext context, 
MessageAck ack) throws
 
         @Override
         public void addMessage(final ConnectionContext context, final Message 
message) throws IOException {
+            // A synchronous add (no future assigned yet) can race a pending
+            // asynchronous add of the same message id 
(concurrentStoreAndDispatch):
+            // the async task still holds the journal/index update while its 
message
+            // has already been counted and dispatched from the cursor cache. 
If the
+            // sync add wins the index it is assigned a real sequence, evades 
the
+            // duplicate suppression in the cursor add path, and inflates the
+            // destination statistics. Reject it here as the duplicate it is; 
the
+            // -1 marker is handled by the existing suppression in
+            // Queue.doPendingCursorAdditions.
+            if (isConcurrentStoreAndDispatchQueues()

Review Comment:
   @cshannon L544 checks for previous entry.
   
   Good call on adding checks in the other two spots, I'll look at those call 
spots.
   
   edit: Those call sites are already under lock, so I believe it is as easy as 
checking for presence and then logging the duplicate add attempt and swallowing 
vs throwing an exception.  
   
   I think the idempotent behavior is a valid approach in this case. Thoughts?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to