Commit 6452bd3
Fix awaitEmpty() race in InFlightWindow
awaitEmpty() had a TOCTOU race between its error check and
in-flight count check. When the I/O thread called fail()
(setting lastError) and then acknowledgeUpTo() (draining the
window to zero) before the flush thread was scheduled, the
while loop exited on the count condition without re-entering
the body to call checkError(). This caused flaky failures in
testErrorPropagation_asyncMultipleBatchesInFlight.
Add a final checkError() after the while loop. Correctness
relies on the happens-before chain through the volatile
highestAcked field: the I/O thread's lastError.set() precedes
its highestAcked write, and the flush thread's highestAcked
read precedes its lastError.get(), so the error is guaranteed
to be visible.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent a1850ca commit 6452bd3
1 file changed
Lines changed: 5 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
290 | 295 | | |
291 | 296 | | |
292 | 297 | | |
| |||
0 commit comments