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

Work on CAMEL-27489 started by shashank.
----------------------------------------
> camel-core - two context reloads at the same time leave a copy of every route 
> in the CamelContext
> -------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27489
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27489
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> {{DefaultContextReloadStrategy.onReload}} has no mutual exclusion. A reload 
> removes all the routes and then creates them again from their definitions, 
> and {{lockModel}} only marks the calling thread. When two reloads overlap, 
> both remove the routes and both create them again, so the context ends with 
> two {{Route}} objects for each route id. Usually nothing fails: both reloads 
> count as succeeded (a single-consumer endpoint such as {{direct:}} makes the 
> copy fail to start, and that reload counts as failed).
> Reloads can come from several threads at once: the secret refresh tasks (AWS, 
> GCP, Azure, HashiCorp on the periodic task thread; Kubernetes and IBM on 
> their own threads), JMX ({{onReload()}}), the developer console and the Camel 
> CLI.
> The extra routes are not started twice (only the last consumer of an id is 
> started), but they stay in {{getRoutes()}}, a later reload does not remove 
> them, and route counts and management views are wrong. In a test with 5 timer 
> routes, 30 rounds of two concurrent reloads left 155 routes.
> h3. How to reproduce
> Hold the first reload after it removed the routes (here in the creation of 
> the first endpoint), start a second reload, then let the first one go on: 
> with routes a ({{pause:}}), b and c ({{direct:}}), the context ends with 
> routes {{[a, a, b, b, c]}}, and the second reload fails on a second consumer 
> of {{direct:b}}.
> Found with a TLA+ model of the context reload: the invariant "at most one 
> reload runs at a time" fails.
> h3. Fix
> {{onReload}} runs under a lock: a reload requested while another one runs 
> waits for it to complete and then runs its own reload (so every request is 
> still served, and each sees the latest state). The lock is reentrant, so a 
> reload that triggers a reload on the same thread does not block.
> _Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to