[ 
https://issues.apache.org/jira/browse/CAMEL-27589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-27589 started by shashank.
----------------------------------------
> camel-core - Aggregate EIP with optimistic locking and 
> closeCorrelationKeyOnCompletion can still start a group for a closed key, and 
> send it as a second aggregate
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27589
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27589
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>             Fix For: 4.24.0
>
>
> h3. What happens
> CAMEL-27297 covered an exchange that reads the repository while a completion 
> is removing the group. Two other orders still let an exchange start a new 
> group for a key that another completion has just closed:
> * Exchange B reads "no group" and passes the closed key checks. Exchange A of 
> the same key then completes on its own (its group is never stored, for 
> example the completion predicate matches the first exchange, or 
> completionSize is 1). A makes no repository call and only closes the key. B 
> then adds its new group, which succeeds because the key has no group.
> * Exchange B reads "no group" and passes the checks. Then A1 stores a group, 
> A2 completes it (removes it and closes the key), and B's add succeeds because 
> the key has no group again.
> A third order sends two aggregates without any stored group: A and B both 
> read "no group", both match the completion predicate (or completionSize is 
> 1), and both complete on their own. Neither makes a repository call, so both 
> are sent and both close the key.
> In the first two cases the group of B lives on for the closed key and is sent 
> later (by its completion timeout, interval, or a force completion) as a 
> second aggregate of that key. B is accepted, although a later exchange of the 
> key is rejected with ClosedCorrelationKeyException. Without optimistic 
> locking this cannot happen, because the aggregator lock is held from the read 
> to the add.
> h3. How to reproduce
> A MemoryAggregationRepository with optimistic locking whose add holds 
> exchange B until the other exchanges are done. With a completion predicate 
> that matches A, the mock receives "A" and then "B". With completionSize 2, it 
> receives "A1+A2" and then "B". With two exchanges that both match the 
> predicate and are held after the closed key checks, both are sent.
> Found with a TLA+ model of the aggregator with optimistic locking (property: 
> at most one aggregate per closed key).
> h3. Fix
> With optimistic locking and closeCorrelationKeyOnCompletion only:
> * An exchange that added a new group checks the key again after the add. If 
> the key is closing or closed, it removes its group again (only while the 
> group still holds only its exchange) and is tried again or rejected with 
> ClosedCorrelationKeyException.
> * A completion of a group that was never stored is done by one exchange of a 
> key at a time. It marks the key as closing too, and then checks that the key 
> still has no group, that no other completion is closing it, and that it is 
> not closed. Otherwise it is tried again, and then aggregates with the new 
> group or is rejected.
> So either the new group sees the key closing, or the completion sees the new 
> group. Routes without optimistic locking, or without 
> closeCorrelationKeyOnCompletion, do not change.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to