shashank created CAMEL-27417:
--------------------------------
Summary: camel-core - in-memory saga: compensate() and complete()
report success while another compensation or completion is still running, which
then fails
Key: CAMEL-27417
URL: https://issues.apache.org/jira/browse/CAMEL-27417
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: shashank
Assignee: shashank
h3. What happens
{{InMemorySagaCoordinator.compensate()}} calls {{end(COMPENSATING)}}. When it
loses the race to start the compensation (to the timeout of a step, or to
another caller), it reads the status once and returns an already successful
future if the status is COMPENSATING. The running compensation can still use up
its retries and set the saga to FAILED. {{complete()}} does the same for
COMPLETING.
* With the Saga EIP in AUTO mode and a step {{timeout}}, a body that outlives
the timeout and then fails: the compensate of the owner loses to the timeout
compensation and gets success at once, so the exchange returns while the
compensation still runs, without the compensation failure that CAMEL-25419
attaches to it, and the saga then ends FAILED.
* A {{saga:compensate}} or {{saga:complete}} call (or a second split part in
MANUAL mode) during the compensation or completion is told the saga was
compensated or completed, also when it then ends FAILED.
Without the race the failure is reported ({{SagaCompensationFailureTest}}), so
this is the window that CAMEL-25419 did not cover.
h3. How to reproduce
A saga step with {{timeout(200ms)}} and a compensation route that blocks and
then throws, {{maxRetryAttempts=1}}; the body waits until the compensation
started and then throws. The exchange returns at once with no suppressed
exception, and the saga then ends FAILED. Or call
{{coordinator.compensate(exchange)}} while the timeout compensation runs: the
future completes successfully at once.
Found with a TLA+ model of the in-memory saga.
h3. Fix
The coordinator keeps the outcome of the compensation or completion that ended
the saga, set together with that change of status. A caller that finds the saga
being finalized the way it asks waits for that outcome and answers from the
final status as before. A call from the compensation or completion exchange of
the same saga (its route calls {{saga:compensate}}) is answered at once, so it
does not wait for itself.
Two low leads of the same model are not changed: {{beginStep}} throws after
enlisting a step when the saga executor is shut down, and a service stop drops
the scheduled timeouts and finalization tasks (documented).
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)