shashank created CAMEL-27528:
--------------------------------
Summary: camel-disruptor - a thread interrupted while it waits for
the event handlers to start or stop loops forever and floods the log
Key: CAMEL-27528
URL: https://issues.apache.org/jira/browse/CAMEL-27528
Project: Camel
Issue Type: Bug
Components: camel-disruptor
Reporter: shashank
Assignee: shashank
h3. What happens
{{DisruptorReference.start()}} and {{shutdownDisruptor()}} (run when a consumer
of a {{disruptor}} endpoint starts, stops, is suspended or resumed, and when
the last endpoint is removed) wait for each event handler with
{{awaitStarted(10, SECONDS)}} / {{awaitStopped(10, SECONDS)}}. The wait sits in
a loop that catches {{InterruptedException}}, logs "Interrupted while waiting
for the startup to complete" (or "...the shutdown...") at INFO, sets the
interrupt flag again and waits again. {{CountDownLatch.await()}} throws at once
while the flag is set, so once the thread is interrupted while an event handler
has not started (or not stopped) yet:
* the thread spins at full CPU, with the lock of the disruptor held, until the
event handler starts (stops), or forever if it never does;
* every iteration logs one INFO line: a test run wrote about 2 GB of log within
a minute.
The 10 s limit, meant to keep an application from hanging, never applies on
this path.
h3. How to reproduce
Interrupt the thread that reconfigures a disruptor whose new event handler does
not start (for example, an executor that holds the tasks it gets):
{{reconfigure()}} never returns and logs the INFO line in a loop. It was seen
in the teardown of a test whose next start could not run its event handler,
where the CamelContext stop timed out and interrupted the shutdown task while
it waited. The wait in {{shutdownDisruptor()}} has the same loop, reached when
the thread is interrupted while an event handler has not stopped yet (between
the halt of its event processor and the end of it).
h3. Fix
The wait never waits again with the interrupt flag set, logs one WARN line and
sets the flag again for the caller at the end. An interrupt does not end the
wait for the start: it goes on, without interruption, for the rest of the 10 s
limit, because producers use the new Disruptor once the start returns, and LMAX
{{Disruptor.shutdown()}} only waits for the event processors that run: a start
that returned before its event processors ran would let the next
reconfiguration halt a ring buffer holding accepted exchanges, which are then
lost without any error. An interrupt ends the wait for the stop:
{{Disruptor.shutdown()}} returned only once the running event processors had
taken every exchange published on the ring buffer, so an event handler that has
not stopped yet has handled every exchange it took and is only shutting down,
as after the 10 s limit.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)