Commit 552bbb7
Fix race condition in sharded hashed dictionary parallel loading
There was a TOCTOU race in the worker thread loop: after `tryPop`
timed out (confirming the queue was empty), a context switch could
allow the main thread to push the final block and call `finish()`
before the worker checked `isFinished()`. The worker would then see
the queue as finished and exit, leaving the last block unprocessed.
This caused occasional loss of ~2000-3000 rows (one shard's portion
of the last source block) in sharded dictionaries loaded in parallel.
The fix replaces `isFinished()` with `isFinishedAndEmpty()`, which
atomically verifies both that the queue is marked finished AND that
no items remain. If items were pushed between the `tryPop` timeout
and this check, the worker correctly retries and processes them.
Closes #84468
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent f3e2aaa commit 552bbb7
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
191 | 199 | | |
192 | 200 | | |
193 | 201 | | |
| |||
0 commit comments