shashank created CAMEL-27519:
--------------------------------

             Summary: camel-disruptor - when the new Disruptor of a 
reconfiguration fails to start, every producer of the queue waits forever, also 
with a timeout
                 Key: CAMEL-27519
                 URL: https://issues.apache.org/jira/browse/CAMEL-27519
             Project: Camel
          Issue Type: Bug
          Components: camel-disruptor
            Reporter: shashank
            Assignee: shashank


h3. What happens

{{DisruptorReference.reconfigure()}} (a consumer of a {{disruptor}} endpoint 
starts, stops, is suspended or resumed) clears the reference and marks it as 
being reconfigured, shuts the old Disruptor down, then calls {{start()}}. If 
{{start()}} throws (the executor of the event handlers rejects them, a thread 
cannot be created), the {{finally}} only unlocks and the mark stays set:
* every producer then waits in {{getCurrentDisruptor()}} forever, also an InOut 
producer with a {{timeout}}, as the timeout only starts after the exchange is 
published;
* {{DelayedExecutor}} keeps the event processors it had not handed over yet, 
and the next {{start()}} hands them to the executor too, where they take 
threads meant for the real event processors.

The route start fails and is reported, but the producers of the queue hang 
instead of failing. The other callers of {{start()}} (an endpoint added again 
after the last one was removed, the move of the event handlers to another 
CamelContext for disruptor-vm) behave the same.

h3. How to reproduce

Give the CamelContext a {{ThreadPoolFactory}} whose pools reject tasks, then 
add a second consumer route on {{disruptor:foo?multipleConsumers=true}}: the 
route start fails with {{RejectedExecutionException}}, and an InOut send with 
{{timeout=1000}} is still waiting in {{getCurrentDisruptor}} after 10 s. No 
natural trigger was found on main (CAMEL-25849 moves the event handlers away 
from a stopping CamelContext); the point is that a failed start must not hang 
the producers.

Found with a TLA+ model of the reconfiguration with an injected {{start()}} 
failure.

h3. Fix

A failed {{start()}} sets the reference to not started, so producers fail at 
once with {{DisruptorNotStartedException}}, drops the event processors still 
queued in {{DelayedExecutor}}, halts the ones already handed over, logs one 
WARN line and rethrows. Buffered exchanges of a queue without consumer stay 
buffered for the next successful start.

_Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to