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

Work on CAMEL-27089 started by shashank.
----------------------------------------
> camel-core - parallel Multicast, Split and Recipient List: an exchange 
> waiting for a part when its route is removed after a forced stop is never 
> completed, and its caller waits for ever
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27089
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27089
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> A parallel Multicast, Split or Recipient List submits its task, and then one 
> task per part, to its thread pool; the last part to be aggregated calls the 
> callback. When the route is removed, {{MulticastProcessor.doShutdown}} (and 
> {{RecipientList.doShutdown}}) shut that pool down with {{shutdownNow}}: the 
> parts still queued are dropped and the exchange waits for them for ever.
> This happens when a route is stopped with a timeout that runs out (the 
> default graceful timeout, or {{stopRoute(id, timeout, unit)}}) and then 
> removed, which is also what a route reload does, while an exchange still 
> waits for a part (a slow part on a busy pool). A synchronous caller 
> ({{ProducerTemplate}} request, {{direct}} caller) then waits for ever, and 
> the exchange stays in the in-flight registry with its unit of work never done.
> Found with a TLA+ model of the protocol (the task and two parts on the pool, 
> route stop with graceful wait or timeout, removal with shutdownNow, running 
> parts that end after it). On main, "once the route is removed and nothing is 
> left to run, the exchange was completed" is violated with the trace: send, 
> stop, timeout, remove. Failing the tasks at shutdown without the task's done 
> flag breaks "the callback is called at most once".
> h3. How to reproduce
> {code:java}
> context.getExecutorServiceManager()
>     .registerThreadPoolProfile(new 
> ThreadPoolProfileBuilder("one").poolSize(1).maxPoolSize(1).build());
> from("direct:block").process(e -> latch.await(20, TimeUnit.SECONDS));
> from("direct:start").routeId("parallel")
>     
> .multicast().parallelProcessing().executorService("one").to("direct:block", 
> "mock:b");
> CompletableFuture<Exchange> f = template.asyncSend("direct:start", e -> {});
> // wait until the first part blocks; the second part is queued in the pool
> context.getRouteController().stopRoute("parallel", 100, 
> TimeUnit.MILLISECONDS);
> context.removeRoute("parallel");
> f.get(10, TimeUnit.SECONDS); // TimeoutException
> {code}
> The same with {{split(body()).parallelProcessing()}} and 
> {{recipientList(body()).parallelProcessing()}}.
> h3. Fix
> The processor keeps its parallel tasks that are not done; after shutting down 
> its own thread pool, doShutdown fails each of them with a 
> RouteStoppingException through doFailed, which uses the same done flag as the 
> other ways a task completes, so the callback is called once. A user-supplied 
> pool that the EIP does not shut down is not affected.
> _Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to