You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix repartition from dropping data when spilling (apache#20672)
## Which issue does this PR close?
- Closesapache#20683
## Rationale for this change
In non-preserve-order repartitioning mode, all input partition tasks
share clones of the same `SpillPoolWriter` for each output partition.
`SpillPoolWriter` used `#[derive(Clone)]` but its `Drop` implementation
unconditionally set `writer_dropped = true` and finalized the current
spill file. This meant that when the **first** input task finished and
its clone was dropped, the `SpillPoolReader` would see `writer_dropped =
true` on an empty queue and return EOF — silently discarding every batch
subsequently written by the still-running input tasks.
This bug requires three conditions to trigger:
1. Non-preserve-order repartitioning (so spill writers are cloned across
input tasks)
2. Memory pressure causing batches to spill to disk
3. Input tasks finishing at different times (the common case with
varying partition sizes)
## What changes are included in this PR?
Adds a `WriterCount` to track the number of writers currently live and
doesn't finalize until all writers are dropped.
## Are these changes tested?
Yes. A new unit test (`test_clone_drop_does_not_signal_eof_prematurely`)
directly reproduces the bug. It was verified to **fail without the fix**
and **pass with the fix**.
## Are there any user-facing changes?
No.
0 commit comments