Repository navigation
Description
Background
Follow-up from #26178. This does not block merging that PR: #26178 fixes the production false-rejection reported in #26174, while this issue tracks a narrower spill-transition accounting gap.
Problem
During shuffle HashBuild, startSpill() can drain retained build batches while the current upstream ingress batch is still live.
The existing accounting proves these paths separately:
- direct spill includes the current upstream batch in
spillBudgetBytes; - retained drain subtracts its source because that source is already covered by
HashmapBuilder.batchReservations.
However, when startSpill() runs before the current result.Batch is released, the simultaneously live recovery state is:
retained source reservations
+ current ingress source
+ retained-drain scratch
The emergency lease can represent the maximum of the isolated direct/retained proofs without proving current ingress source + retained-drain scratch as one overlap state. Under a tightly separated cap, the retained drain can therefore start while one live ingress allocation is not represented by the HashBuild budget ledger.
Impact
- No known wrong result, data corruption, or transaction correctness impact.
- Limited to the shuffle HashBuild transition into spill with both a retained queue and a live ingress batch.
- Under a tight query/CN memory cap, the transient peak can exceed the intended HashBuild cap and turn a controlled admission failure into an allocation failure or OOM risk.
- The missing amount is normally about one ingress batch, but it is not always tiny because a reused batch may retain a large backing allocation.
Suggested scope
Keep the fix on the spill-transition cold path:
- Let
startSpill()know whether a current ingress batch is still live. - Before draining retained batches, explicitly prove/reserve the combined
live ingress source + maximum retained-drain scratchpeak. - Release or reconcile transition-only accounting after the retained queue is drained.
- Avoid adding a second per-row estimator pass to the normal non-spill build path.
Regression coverage
Add an operator-level test with a retained queue plus one live ingress batch:
- choose a cap that admits the isolated retained-drain lease but not the combined overlap and verify fail-closed behavior before spill scratch allocation;
- raise the cap to cover the combined peak and verify retained drain plus direct spill succeeds;
- verify reservations, mpool memory, spill disk, and file descriptors are released on both paths.
Activity