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

Work on CAMEL-27414 started by shashank.
----------------------------------------
> camel-core - Supervising route controller: a route removed while its last 
> restart attempt is marked exhausted stays exhausted, and the controller 
> unhealthy, for ever
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27414
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27414
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> {{ManagedRoutePolicy.onRemove}} takes {{lock}}, which is the policy's own 
> lock (inherited from {{BaseService}}), not the lock of 
> {{DefaultSupervisingRouteController}}. So {{removeRoute}} (or a route reload) 
> releases the route without the controller lock, in the middle of steps the 
> controller does under its lock:
> * The completion of an exhausted restart task checks under the controller 
> lock that the task is still the restart task of the stopped route, logs the 
> WARN, and puts the route into the exhausted routes. A {{removeRoute}} between 
> the check and the put leaves the removed route in the exhausted routes for 
> ever: {{hasUnhealthyRoutes()}} stays true (with {{unhealthyOnExhausted}}, the 
> default, the route controller readiness check {{camel/route-controller}} 
> stays DOWN until the JVM restarts), and {{getExhaustedRoutes()}} lists a 
> route that does not exist.
> * A manual {{startRoute}} that fails releases the route lock of the 
> CamelContext before it installs a restart task. A {{removeRoute}} in between 
> leaves a restart task for the removed route: the route is reported restarting 
> and the controller unhealthy (with {{unhealthyOnRestarting}}, the default) 
> until the next attempt (one {{backOffDelay}}), which starts the route by id 
> (a no-op, or a route added again with the same id).
> Taking the controller lock in {{onRemove}} would deadlock with a manual start 
> or stop (route lock vs controller lock in the opposite order).
> h3. How to reproduce
> A route whose consumer fails to start, {{backOffMaxAttempts=2}}: hold the 
> scheduler thread in the "is exhausted after" WARN and call {{removeRoute}}; 
> after the completion goes on, {{getExhaustedRoutes()}} lists the removed 
> route and {{hasUnhealthyRoutes()}} is true.
> Found with a TLA+ model of the restart tasks, manual start/stop and 
> removeRoute.
> h3. Fix
> {{onRemove}} removes the route from the controlled routes before it releases 
> it. After putting a route into the exhausted routes, and after installing a 
> restart task, the controller checks that the route is still controlled and 
> otherwise undoes it; either the release comes later and removes it, or the 
> check sees the route gone. No lock is added.
> _Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to