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
HashBuild producer-side spill cleanup drops a physical file after a temporary RemoveFile failure: spillFileBundle.release marks the bundle released, clears its entries and releases its disk reservation even though the file still exists. A later cleanup cannot retry. This is a separate owner path from JOIN probe writer #30097 and handed-off consumer #30100.
Environment
Branch: official main
Commit: 21f19ae06305ca2acd253d15123f851899d6b6a1
Deployment: isolated local Go test using the production HashBuild spill bundle and local mutable file service.
Steps to reproduce
Create one physical spill file and reserve its exact disk bytes in an ExecutionResourceGeneration.
Install the file as a created spillFileBundle entry. Wrap only RemoveFile so deletion fails while all other file operations remain normal.
Call HashBuild.cleanupSpillFiles, then inspect the file, SpillDiskUsed, and the bundle ownership. Clear the injected error and call cleanup again.
The reproducer is in PR #30102, pkg/sql/colexec/hashbuild/spill_bundle_cleanup_test.go.
Actual behavior
The file remains openable after cleanup, while SpillDiskUsed becomes zero and the operator loses its bundle pointer.
A second cleanup has no file name or reservation to retry.
The fault path reproduced 3/3 on official main; the identical healthy control removed the file and returned disk usage to zero.
Expected behavior
Keep the failed entry and disk reservation until removal succeeds. A later Reset, Free, or Prepare should retry instead of overwriting the pending cleanup owner.
Code analysis
pkg/sql/colexec/hashbuild/types.go: spillFileBundle.release discarded the RemoveFile result and unconditionally released the disk token. HashBuild.cleanupSpillFiles then cleared the bundle pointer. The same ownership loss was possible in the build failure defer.
Regression coverage
PR #30102 adds the fault/control Go test. The fix passed the six related Go package suites and the new test with -race -count=20 locally.
Related
#30097 covers probe-side BucketWriter; #30100 covers already handed-off SpillFile. This issue covers producer-side HashBuild.spillFileBundle before handoff.
Activity
Ariznawlll commentedon Oct 30, 2026
结论
测试不通过。实际 SQL 的 JOIN spill 在创建和删除同时受阻、并发取消后出现临时文件残留;该现象与本 issue 的 HashBuild 清理路径相关,但尚未单独隔离删除失败。
关键证据
main@bbfe55669a1440424914d45a283a1d0e36f722fa;本地隔离双 CN、单 TN。join_spill_mem=1000;观察到 170 个 spill 文件后,临时移除 spill 目录写权限并发出KILL QUERY。查询返回20101,具体原因是创建join_hb_*_build文件时 permission denied;恢复权限后仍有 181 个文件,连接的SELECT 1正常。该混合注入目前观察 1 次。spillFileBundle.release忽略RemoveFile返回值;文件名前缀和故障时机与该路径相符,但这次 SQL 现象不能单独证明具体所有权阶段。待解决点
RemoveFile失败、其他文件操作正常的条件下,重复验证具体清理路径和权限恢复后的重试;现有 SQL 故障同时阻断文件创建与删除。Ariznawlll commentedon Nov 4, 2026
结论
测试不通过。仅注入 spill 文件删除失败时,HashBuild 丢失文件清理所有权并提前释放磁盘记账;文件系统恢复后再次清理仍无法删除残留文件。
关键证据
main@0f6c07639604c40d7ca880cb63d1d282239def08,macOS arm64,独立 Go 测试进程;使用生产 HashBuild bundle 和真实本地 spill 文件,仅对RemoveFile注入错误,不阻断文件创建、写入和读取。SpillDiskUsed=0。待解决点