[
https://issues.apache.org/jira/browse/CAMEL-27356?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27356 started by shashank.
----------------------------------------
> camel-resilience4j - in asynchronous mode, a blocking fallback after a
> timeout holds a timeout thread, and with 10 of them held the next timeouts do
> not fire
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27356
> URL: https://issues.apache.org/jira/browse/CAMEL-27356
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: shashank
> Assignee: shashank
> Priority: Major
>
> h3. What happens
> Since CAMEL-27212 the timeouts of a Circuit Breaker with
> {{asynchronous=true}} and {{timeoutEnabled=true}} run on a scheduled thread
> pool of their own ({{CircuitBreakerTimeout}}, the size of the default thread
> pool profile, 10 threads). When a timeout fires, its thread completes the
> future exceptionally, and the {{whenComplete}} of
> {{ResilienceProcessor.processAsync}} runs the fallback and then the rest of
> the route ({{callback.done(false)}}) on that same thread.
> If the fallback blocks (a common fallback calls a backup HTTP service), or a
> step after the Circuit Breaker blocks, each such exchange holds a timeout
> thread. With 10 of them held, the next timeouts wait: an exchange whose call
> hangs no longer gets its fallback, until one of the blocked fallbacks
> returns. This is the starvation that CAMEL-27212 fixed for the calls, one hop
> later. It is documented as a caveat on the Resilience4j EIP page; the review
> of CAMEL-27212 agreed to hand the continuation off the scheduler thread in a
> follow-up.
> h3. How to reproduce
> An asynchronous Circuit Breaker with {{timeoutDuration=200}}, calls that
> block, and a fallback that blocks for the first 10 exchanges: the 11th
> exchange, whose call also blocks, gets no reply (its timeout does not fire).
> Found with a TLA+ model of the timeouts and their continuations.
> h3. Fix
> After a timeout, hand the continuation to a cached thread pool of the Circuit
> Breaker ({{CircuitBreakerFallback}}), created and shut down with the timeout
> scheduler; if that pool rejects the task (route removed), continue on the
> timeout thread. The thread pool of the calls cannot take it: when the calls
> block every thread of it, the fallback would wait behind them.
> Not in this change: the ScheduledExecutorService requirement for
> {{timeoutExecutorService}} in asynchronous mode (stale since CAMEL-27212,
> that pool only runs the calls) and the stale "uses ForkJoinPool.commonPool()
> by default" description; that cleanup touches generated metadata and is a
> separate follow-up.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)