[
https://issues.apache.org/jira/browse/CAMEL-27412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27412 started by shashank.
----------------------------------------
> camel-core - Aggregate EIP: a recover check that ends during a route restart
> can clear the snapshot of the new check, which then sends an exchange in
> progress again
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27412
> URL: https://issues.apache.org/jira/browse/CAMEL-27412
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: shashank
> Assignee: shashank
> Priority: Minor
>
> h3. What happens
> With a recoverable aggregation repository,
> {{AggregateProcessor.RecoverTask.run}} ends with
> {code:java}
> } finally {
> recoveryInProgress.set(false);
> inProgressCompleteExchangesForRecoveryTask.clear();
> }
> {code}
> CAMEL-26642 made a recover check start only when no other check runs
> ({{recoveryInProgress.compareAndSet(false, true)}}), because a route stop
> does not wait for a running check. But the flag is cleared before the shared
> snapshot of the exchanges in progress. If the route was stopped and started
> while the old check was running, the recover task of the new start can win
> the compareAndSet in that gap, clear the snapshot and fill it with the
> exchanges in progress and the unconfirmed ones. The old check then runs its
> {{clear()}} and empties the snapshot of the new check. The new check scans
> the repository, finds the exchange neither in the (now empty) snapshot nor
> among the exchanges being completed, and recovers and sends it:
> * an exchange that is still being processed is processed a second time (with
> {{parallelProcessing}} at the same time, by two threads);
> * an exchange that was processed and whose confirm returned false (kept as
> unconfirmed) is sent again.
> It needs a route restart while a check runs, and the old check must end at
> the moment the first check of the new start takes its snapshot.
> h3. How to reproduce
> A test replaces the snapshot set with a set that behaves the same and holds
> the old check inside the {{clear()}} of its finally block; while it is held
> the route is restarted. The new check starts, takes its snapshot, and after
> the old check's {{clear()}} it recovers the exchange: {{recovered=1}}, the
> exchange is delivered twice (with {{parallelProcessing}},
> {{maxConcurrent=2}}).
> Found with a TLA+ model of the recover task, the completions and a route
> restart.
> h3. Fix
> Clear the snapshot first, then set {{recoveryInProgress}} to false, so a new
> check can only start once the old one has cleared the snapshot.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)