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

shashank updated CAMEL-27501:
-----------------------------
    Fix Version/s: 4.25.0

> camel-core - Wire Tap EIP: on a thread pool that is shut down every tap is 
> lost silently and counted as pending for ever
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27501
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27501
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>             Fix For: 4.25.0
>
>
> h3. What happens
> The Wire Tap counts a tap as pending ({{taskCount}}) before it submits it, 
> and only a thrown exception takes it off again. With the CallerRuns rejected 
> policy (the default), a thread pool that is shut down drops the task without 
> running it and without an exception, so:
> * every tap is lost, with nothing logged and no error on the exchange;
> * each lost tap stays in {{getPendingExchangesSize()}}, which the graceful 
> shutdown uses, so stopping the route always waits until the shutdown timeout 
> for tapped exchanges that do not exist ("Waiting as there are still ... 
> inflight and pending exchanges").
> This happens with {{wireTap(...).executorService(pool)}} on a pool that its 
> owner shut down. With the Block policy, a tap whose caller was released by 
> the {{shutdownNow}} of the route's own pool (the drain makes space) is put 
> into the queue of the dead pool and stays counted after the processor is shut 
> down.
> h3. How to reproduce
> {{from("direct:start").wireTap("mock:tapped").executorService(shared).to("mock:main")}}
>  with {{shared}} from {{newDefaultThreadPool}}; {{shared.shutdown()}}; send 3 
> messages: mock:main gets them, mock:tapped gets none, 
> {{getPendingExchangesSize()}} is 3, and {{stopRoute}} takes the whole 
> shutdown timeout.
> Found with the same TLA+ model as the Threads EIP issue ("the pending count 
> is honest" fails), and reproduced with JUnit.
> h3. Fix
> Each tap gets its own claim flag; the task, a check after the submit and 
> {{doShutdown}} each claim the tap first, so a tap is sent or counted as lost, 
> never both. For the Wire Tap's own thread pool the claims of the taps that 
> have not started are kept in a set for {{doShutdown}} (not for a thread pool 
> of the user, which may drop tasks while it runs). When the thread pool is 
> shut down after the submit, a tap that has not started is counted as lost: it 
> is taken off the pending count, its exchange is released, and a WARN names 
> the tap endpoint and the exchange id (the tapped message is lost). The 
> original exchange is not affected. {{doShutdown}} takes the taps that never 
> started off the count through the same claim.
> Major rather than Minor: tapped messages (often audit or monitoring copies) 
> are lost without any trace, and every graceful stop of such a route runs into 
> its timeout.
> _Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to