[
https://issues.apache.org/jira/browse/CAMEL-27009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150946#comment-18150946
]
Federico Mariani commented on CAMEL-27009:
------------------------------------------
Thanks Claus, I'm keeping this one. The fix options in the description needed a
second look before picking one; corrections and a plan below.
The attached test still fails on main (fb35484329e9), 5 of 5.
*Corrections to the description*
* Option 2 does not work as described. A route stop clears the route input
({{RouteService.doStop()}} sets {{input = null}}), and starting the route again
creates a new consumer ({{DefaultRoute.gatherRootServices()}} ->
{{endpoint.createConsumer(processor)}}): the restart does not wait for the
stuck consumer. When the stuck call returns later, the old consumer's
{{DefaultConsumer.doStop()}} stops the route processor that the new consumer is
using. Making the skip safe needs coordination with restart, remove, abort, the
route events and the JMX status: much more than two classes.
* Option 1 also misses {{BaseService.shutdown()}}, which takes the same lock:
{{ServiceHelper.stopAndShutdownService()}} calls it right after {{stop()}}.
* The {{shutdownForced}} stack applies to the three context-stop tests only.
The route stops reach the same wait through
{{DefaultShutdownStrategy.shutdown()}}.
* Two more effects of a blocked suspend/stop: a route stop with a timeout holds
the CamelContext lock while it waits
({{AbstractCamelContext.doShutdownRoute()}}), so other route operations wait
too; and the graceful shutdown runs on a single {{ShutdownTask}} thread, so any
fix that leaves the blocked call behind also delays the graceful part of the
next shutdown.
* CAMEL-27001 bounded the SFTP producer stop; the SFTP consumer stop was
CAMEL-27018.
*Plan*
Keep {{stop()}} synchronous (as decided in CAMEL-7623 and CAMEL-13310) and fix
the components where the call blocks, all in this ticket and one PR:
# camel-core: when the timeout elapses while the shutdown task is still inside
a consumer's suspend or stop, the WARN names that route and consumer, so a stop
that hangs points at its cause. The {{DefaultShutdownStrategy}} javadoc and
graceful-shutdown.adoc say that the timeout is when Camel switches to the
forced shutdown, and that a consumer whose suspend or stop does not return can
make the stop take longer. I'll update the summary to match.
# camel-spring-rabbitmq: bound the suspend/stop of the listener container when
the broker does not answer basic.cancel (today up to {{channelRpcTimeout}}, 10
minutes by default).
# camel-jms: the same for the suspend of the listener container
({{JmsConsumer.doSuspend()}} calls {{listenerContainer.stop()}} inline;
{{asyncStopListener}} covers only the stop).
A stop with a deadline for the caller (returning "still stopping" instead of
waiting) could be a separate improvement later; it is not part of this fix.
Unless you prefer a change in core, I'll open the PR this week.
_Claude Code on behalf of Croway_
> camel-core - the shutdown timeout does not bound CamelContext.stop() or a
> route stop when a consumer's suspend or stop blocks: the forced shutdown
> waits for the service lock held by the graceful shutdown task
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27009
> URL: https://issues.apache.org/jira/browse/CAMEL-27009
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: Federico Mariani
> Assignee: Federico Mariani
> Priority: Major
> Fix For: 4.25.0
>
> Attachments: DefaultShutdownStrategyBlockedConsumerTest.java
>
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)