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
{{ message }}
Repository navigation
[Bug]: handed-off JOIN spill files remain on disk after transient removal error #30100
After a JOIN build spill file has been transferred from spillutil.BucketWriter to message.SpillFile, a transient RemoveFile error permanently leaves the physical spill file behind. SpillFile.Close records that error under removeOnce, clears the remover, and releases the disk reservation anyway. A later Close cannot retry removal, while SpillDiskUsed() already reports zero. Repeated failures can therefore accumulate untracked files on disk.
This is the post-handoff owner path in pkg/vm/message/joinMapMsg.go, distinct from the writer cleanup before handoff in #30097 / #30099 and from GROUP/DISTINCT cleanup in #30098. SpillBuildPayload.Close also discards its file handles after a close error, and JoinMap.FreeMemory ignores the error, so the caller has no later recovery path.
Reproduction and actual result
Verified on main 175a645a85994f2c95992d3aa8d6dacb6d9e167f with a real BucketWriter write and handOffSpillFile, wrapping its file service to fail the first RemoveFile call only:
Write a spill bucket and hand its file to SpillFile; SpillDiskUsed() > 0.
Call SpillFile.Close(); the injected removal error is returned.
The file can still be opened, but SpillDiskUsed() == 0.
Call SpillFile.Close() again after the file service is healthy; it returns the cached error without calling RemoveFile again. The file remains.
Normal-path control deletes the file and releases the reservation. The fault/control probe was repeated 20 times with go test -race; all observations were consistent. The probe used a temporary test file and was not committed.
Expected
A failed deletion should not silently lose the last cleanup opportunity while reporting its disk reservation released. Cleanup ownership and accounting should remain coherent until the file has actually been removed, with an actionable error/retry path through payload and JOIN teardown.
Relevant code
pkg/sql/colexec/spillutil/join_spill.go: BucketWriter.handOffSpillFile transfers the remove callback and disk reservation.
pkg/vm/message/joinMapMsg.go: SpillFile.Close, SpillBuildPayload.Close, and JoinMap.FreeMemory handle teardown after transfer.
Activity
Ariznawlll commentedon Nov 4, 2026
结论
测试不通过。JOIN spill 文件实际移交给消费端后,第一次删除失败会释放磁盘记账并丢失重试机会,文件系统恢复后文件仍然残留。
关键证据
main@0f6c07639604c40d7ca880cb63d1d282239def08,macOS arm64,独立 Go 测试进程和真实本地 spill 文件。使用生产BucketWriter写入实际记录,并通过handOffSpillFile移交,写入后先确认磁盘记账大于零;只让第一次RemoveFile返回注入错误。SpillFile.Close()返回删除错误,物理文件仍可打开,但SpillDiskUsed=0;底层后续删除已恢复时再次 Close,仍返回缓存的原错误,删除调用次数保持 1,文件继续存在。无故障对照 3/3:文件成功删除,记账归零,重复 Close 不报错。SpillFile和实际磁盘 reservation 复核同一消费端 Close 路径,故障及正常对照各 3/3,结果一致。测试最后显式清理诊断文件。当前实现使用一次性删除和独立释放回调,与观察一致。待解决点