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

Work on CAMEL-27591 started by shashank.
----------------------------------------
> camel-jms, camel-sjms - a request timeout handed to the timeout executor 
> after the reply manager stopped is dropped, and the exchange never completes
> -----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27591
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27591
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jms, camel-sjms
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>             Fix For: 4.24.0
>
>
> h3. What happens
> The timeout checker of the reply manager removes all expired requests from 
> the correlation map under the map lock, then hands their timeout tasks to the 
> on-timeout executor one by one, outside the lock 
> ({{CorrelationTimeoutMap.submitEviction}}). With the default {{CallerRuns}} 
> rejected policy and a full executor, a timeout task, and the rest of the 
> routing of its exchange, runs in the checker thread.
> The stop of the reply manager waits for the checker for at most twice the 
> {{shutdownAwaitTermination}} (10 seconds by default), shuts the on-timeout 
> executor down and completes the timeout tasks it did not run 
> ({{completePendingEvictions}}, CAMEL-27321). If the checker is still busy 
> routing an exchange at that point, it later hands its remaining expired 
> requests to the shut-down executor. {{CallerRuns}} on a shut-down executor 
> drops the task without an exception (it is the JDK {{CallerRunsPolicy}}), so 
> the catch of {{RejectedExecutionException}} in {{submitEviction}} does not 
> run. The task stays in {{pendingEvictions}}, {{AsyncCallback.done}} is never 
> called, and the exchange never completes (a synchronous caller waits for 
> ever).
> It needs a mass timeout that fills the executor, and an exchange whose 
> routing in the checker thread outlasts both waits of the stop.
> h3. How to reproduce
> A reply manager with a one-thread on-timeout executor with a queue of one and 
> {{CallerRuns}}, and a {{shutdownAwaitTermination}} of 200 ms. Four requests 
> time out in the same check: the first task holds the executor thread, the 
> second is queued, the third runs in the checker thread and its routing blocks 
> (ignoring the interrupt). Stop the reply manager, then let the routing end: 
> the fourth request is never completed.
> Found with a TLA+ model of the reply correlation (property: every request is 
> completed; with a purge slower than the stop's waits it fails).
> h3. Fix
> {{submitEviction}} runs the task in the calling thread when the executor is 
> shut down after the submit, as it already does when the executor throws 
> {{RejectedExecutionException}}. The task runs at most once (it is claimed 
> with a CAS), so a task that the executor took before the shutdown is not 
> completed twice. The same change in camel-sjms, which has a copy of the class.
> _Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to