[
https://issues.apache.org/jira/browse/CAMEL-27422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27422 started by shashank.
----------------------------------------
> camel-core - Aggregate EIP: when a recoverable repository throws while
> confirming a discarded group, the recover task sends the discarded group
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27422
> URL: https://issues.apache.org/jira/browse/CAMEL-27422
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: shashank
> Assignee: shashank
> Priority: Minor
>
> h3. What happens
> With a recoverable aggregation repository (for example
> {{JdbcAggregationRepository}}) and {{discardOnCompletionTimeout}} or
> {{discardOnAggregationFailure}}, a discarded group is first moved to the
> completed store by {{remove}}, and then confirmed by
> {{AggregateProcessor.discard}}:
> {code:java}
> // must confirm the discarded exchange
> aggregationRepository.confirm(aggregated.getContext(),
> aggregated.getExchangeId());
> {code}
> Nothing is around this call. When the confirm throws (for example a transient
> database error), the exception leaves {{onCompletion}}, whose finally block
> clears the mark that the exchange is being completed, and the completion
> timeout checker only logs it and tries the key again (the group is no longer
> in the repository, so that does nothing). The completed row stays in the
> completed store, nobody holds it as in progress or as not confirmed, and the
> next recover pass recovers it and sends the discarded group to the route,
> marked as redelivered. With {{discardOnAggregationFailure}} the message whose
> aggregation failed also fails with the repository exception. Force discarding
> a group ({{AggregateController.forceDiscardingOfGroup}}) goes through the
> same {{discard}}.
> CAMEL-26995 fixed this for a processed exchange and CAMEL-27008 for an
> exchange moved to the dead letter channel: a confirm that throws or returns
> false keeps the exchange as not confirmed, so the recover task confirms it
> again and does not send it again. The discard path did not get the same
> treatment.
> h3. How to reproduce
> {{JdbcAggregationRepository}} on H2 whose first {{confirm}} throws
> {{TransientDataAccessResourceException}}, {{completionTimeout(1000)}},
> {{discardOnCompletionTimeout()}}, recovery every 500 ms: the discarded group
> "AB" reaches the route with {{CamelRedelivered=true}} and
> {{CamelAggregatedCompletedBy=timeout}} (4 runs out of 4).
> Found with a TLA+ model of the remove, confirm and recover steps, which also
> shows that keeping the id as not confirmed is not enough when a recover pass
> has already taken its snapshot of the exchanges in progress before the
> discard: that pass must see the id as well.
> h3. Fix
> For a recoverable repository, {{discard}} calls {{confirmWithResult}} and,
> when it throws or returns false, keeps the exchange as not confirmed and logs
> a WARN, as {{onComplete}} does since CAMEL-26995 and the dead letter path
> since CAMEL-27008. While a recover pass runs, the id is also added to the
> snapshot of that pass, as {{onSubmitCompletion}} does for a new exchange in
> progress. Both happen while the exchange is still marked as being completed.
> A repository that is not recoverable is called as before. With a recoverable
> repository whose confirm fails, {{forceDiscardingOfGroup}} and
> {{forceDiscardingOfAllGroups}} therefore no longer throw, and with
> {{discardOnAggregationFailure}} the message whose aggregation failed no
> longer fails; the failure is logged at WARN.
> Not changed: the set of exchanges that are not confirmed is in memory, so
> after a JVM restart a discarded group whose confirm failed and was not
> retried yet is recovered, as for a processed exchange.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)