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

   ## Description
   
   Fixes the flaky `BacklogTracerMessageHistoryMulticastSedaTest` (about 2% of 
the runs, 
[Develocity](https://develocity.apache.org/scans/tests?search.relativeStartTime=P28D&search.timeZoneId=Europe%2FParis&tests.container=org.apache.camel.management.BacklogTracerMessageHistoryMulticastSedaTest)):
 the Awaitility assertion `Should contain slow-route events (async branch via 
seda)` timed out after 10 seconds.
   
   ### Root cause
   
   This is a bug in `BacklogTracer`, not a timing problem of the test. In 
`traceEvent`, the "last" event of a route was merged into the complete history 
only if its route matched the route of the head of the provisional queue 
(`original`).
   
   With `multicast().parallelProcessing()` to `seda:fast` and `seda:slow`, 
`fast-route` can start before the starter route is finished, so the head of the 
provisional queue is the first event of `fast-route`. When `slow-route` 
finishes (append mode, the history of the starter route being already 
completed) its route does not match the head: its events stay in the 
provisional queue and are never merged. Waiting longer cannot help.
   
   Captured events of a failing run (CPU-loaded machine): `starter`, 
`fast-route` only, no `slow-route`.
   
   ### Fix
   
   Always merge the last event of a downstream route when in append mode: 
`event.isLast() && (original || appendMode)`.
   
   ### Tests
   
   - New deterministic `BacklogTracerMessageHistoryDownstreamOrderTest`: feeds 
the events directly to the `BacklogTracer` in the order that triggers the 
problem (no threads, no SEDA, no timing). Without the fix it fails with 
`expected: <[fast-route, starter, slow-route]> but was: <[starter, 
fast-route]>`, with the fix it passes.
   - `BacklogTracerMessageHistoryMulticastSedaTest` repeated 150 times with all 
cores busy: 1-2 failures before the fix, 0 after.
   - All `BacklogTracer*` and `*MessageHistory*` tests of `camel-management` 
pass.
   
   Jira: https://issues.apache.org/jira/browse/CAMEL-27596
   
   _Bob (IBM Bob 2.2.1) on behalf of apupier_
   


-- 
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