davsclaus opened a new pull request, #24637:
URL: https://github.com/apache/camel/pull/24637

   ## Summary
   
   - Fix race condition in `BacklogTracer.traceEvent()` where concurrent calls 
from multiple threads (e.g. timer thread and Kafka consumer threads) could 
corrupt the message history queue state
   - The compound queue operations (peek/offer/addAll/clear) on 
`provisionalHistoryQueue` and `completeHistoryQueue` must be atomic — without 
synchronization, interleaving threads can cause events to be dropped and the 
complete history to become permanently stale
   
   ## Root Cause
   
   When a route topology includes downstream routes connected via Kafka/SEDA, 
the originating route's thread and the downstream consumer threads call 
`traceEvent()` concurrently. The race window:
   
   1. E0 completes on timer thread → transfer to complete queue → provisional 
cleared
   2. Downstream route (Kafka consumer thread) starts → its first event enters 
provisional as head
   3. E1 fires on timer thread → head belongs to downstream route (different 
breadcrumbId) → E1 events fail match check → **all E1 events dropped**
   4. Complete history queue never gets updated with new exchange data
   
   This was observed as the TUI Inspect tab showing 20-hour-old data from the 
first successful exchange, despite thousands of subsequent exchanges completing.
   
   ## Fix
   
   Add `synchronized (historyLock)` around the message history section of 
`traceEvent()`. Only the history queue management is synchronized — the main 
backlog queue and activity queue processing remain lock-free. The lock scope is 
minimal (local variable reads and queue operations).
   
   ## Test plan
   
   - [x] All 21 `BacklogTracer*Test` tests pass
   - [ ] Manual verification: run a multi-route topology with Kafka/SEDA 
downstream routes and confirm the Inspect tab shows recent exchange data
   
   _Claude Code on behalf of davsclaus_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to