Skip to content

test(qwp): make error dispatcher overflow test deterministic - #86

Merged
ideoma merged 3 commits into
mainfrom
fix-error-dispatcher-test-race
Aug 11, 2026
Merged

test(qwp): make error dispatcher overflow test deterministic#86
ideoma merged 3 commits into
mainfrom
fix-error-dispatcher-test-race

Conversation

@kafka1991

@kafka1991 kafka1991 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The QWP error dispatcher drops the oldest queued entry when its bounded inbox overflows. testFullInboxDropsOldestAndCounts fills the inbox to capacity and asserts that two offers beyond capacity produce exactly two drops.

The test slept 50ms after the first offer and assumed the dispatcher thread had already taken the head entry into the blocked handler, freeing an inbox slot. On a loaded Windows CI machine the thread start exceeded 50ms, so the inbox filled one offer early and the overflow path dropped three entries instead of two, failing the dropped-count assertion. Observed on a Windows CI run:

[ERROR] io.questdb.client.test.cutlass.qwp.client.sf.cursor.SenderErrorDispatcherTest.testFullInboxDropsOldestAndCounts -- Time elapsed: 0.291 s <<< FAILURE!
java.lang.AssertionError: expected:<2> but was:<3>
	at junit@4.13.2/org.junit.Assert.assertEquals(Assert.java:633)
	at io.questdb.test/io.questdb.client.test.cutlass.qwp.client.sf.cursor.SenderErrorDispatcherTest.testFullInboxDropsOldestAndCounts(SenderErrorDispatcherTest.java:136)

02:01:03.894 [main] WARN io.questdb.client.cutlass.qwp.client.sf.cursor.SenderErrorDispatcher -- error-dispatcher thread did not exit within drain deadline; abandoning 3 queued errors

The teardown warning corroborates the timeline: close() found the dispatcher blocked in the handler holding entry 3 with entries 4-6 still queued, so entries 0-2 were the dropped set -- the drop-oldest path itself behaved correctly.

The handler now counts down a handlerEntered latch on entry, and the test awaits it instead of sleeping. dispatchLoop polls the head off the inbox before invoking the handler, so the latch firing proves the slot is free and later offers cannot borrow it.

testFullInboxDropsOldestAndCounts slept 50ms after the first offer and
assumed the dispatcher thread had already taken the head entry into the
blocked handler, freeing an inbox slot. On a loaded Windows CI machine
the thread start exceeded 50ms, so the inbox filled one offer early and
the overflow path dropped three entries instead of two, failing the
dropped-count assertion with expected:<2> but was:<3>.

The handler now counts down a handlerEntered latch on entry, and the
test awaits it instead of sleeping. dispatchLoop polls the head off the
inbox before invoking the handler, so the latch firing proves the slot
is free and later offers cannot borrow it.
@kafka1991 kafka1991 changed the title test(qwp): Make full-inbox drop-oldest test deterministic test(qwp): make error dispatcher overflow test deterministic Aug 10, 2026
jerrinot
jerrinot previously approved these changes Aug 11, 2026
@ideoma
ideoma enabled auto-merge (squash) August 11, 2026 08:56
The full-inbox test assumed the dispatcher thread entered the listener
within 50 ms. Slow scheduling left the first event queued and changed the
expected overflow count.

Wait for listener entry before filling the inbox so the test establishes
the required queue state explicitly.
@ideoma
ideoma merged commit 2489b24 into main Aug 11, 2026
14 checks passed
@ideoma
ideoma deleted the fix-error-dispatcher-test-race branch August 11, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants