Repository navigation
fix(hnsw): stop NewHnswSync orphaning model files and spill to the resolved dir (#29253) - #29334
Conversation
…solved dir (matrixorigin#29253) DownloadAll loads each metadata model with view=false, which KEEPS the committed local file. Two problems on the ISCP CDC sync path (SqlContext, nil Proc): 1. Orphan on error. If a later model's LoadIndex/Unload failed after earlier models committed their files, NewHnswSync did `return nil, err` without Destroy. runHnsw only Destroys a non-nil sync, so the earlier committed files leaked -- one FileSize file per ISCP retry of an index with two or more model rows. Call sync.Destroy() on the DownloadAll error branch before returning. 2. Wrong directory. LoadMetadata builds models with an empty TmpDir and DownloadAll never copied sync.tmpDir onto them, so hnswSpillDir -- which returns "" for a nil Proc -- left os.CreateTemp using os.TempDir(). Those files sit outside the tree HostSpillDir.sweepOnce reclaims, and on the success path park there for the whole consumer lifetime. Set m.TmpDir = s.tmpDir before LoadIndex so spills land in the directory the ISCP writer already resolved (NewSync -> syncSpillDir). Tests (CGo, real usearch load over the 2-model resource fixtures): - TestDownloadAllPlacesModelsInResolvedSpillDir: both models spill into the resolved dir (2 files), Destroy clears them. Fails without fix 2 (0 files -> os.TempDir). - TestNewHnswSyncRemovesCommittedFilesOnDownloadAllError: model abc-0 commits, abc-1's stream fails; the resolved dir is clean afterward. Fails without fix 1 (1 orphan). The setupModel dropped-error path noted in the issue is a separate concern and not the orphan source; left out of scope. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 high review — APPROVE at exact head 77a9300.
Reviewed both changed paths and their lifecycle: DownloadAll now routes temporary model files through the resolved spill directory, and NewHnswSync destroys already-committed files when a later model load fails. The added tests cover both the spill-location and partial-download cleanup cases; exact-head CI/UT/BVT evidence is green. No blocking findings.
Merge Queue Status
This pull request spent 20 minutes 10 seconds in the queue, with no time running CI. ReasonHintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #29253
What this PR does / why we need it:
DownloadAll loads each metadata model with view=false, which KEEPS the committed local file. Two problems on the ISCP CDC sync path (SqlContext, nil Proc):
Orphan on error. If a later model's LoadIndex/Unload failed after earlier models committed their files, NewHnswSync did
return nil, errwithout Destroy. runHnsw only Destroys a non-nil sync, so the earlier committed files leaked -- one FileSize file per ISCP retry of an index with two or more model rows. Call sync.Destroy() on the DownloadAll error branch before returning.Wrong directory. LoadMetadata builds models with an empty TmpDir and DownloadAll never copied sync.tmpDir onto them, so hnswSpillDir -- which returns "" for a nil Proc -- left os.CreateTemp using os.TempDir(). Those files sit outside the tree HostSpillDir.sweepOnce reclaims, and on the success path park there for the whole consumer lifetime. Set m.TmpDir = s.tmpDir before LoadIndex so spills land in the directory the ISCP writer already resolved (NewSync -> syncSpillDir).
Tests (CGo, real usearch load over the 2-model resource fixtures):
The setupModel dropped-error path noted in the issue is a separate concern and not the orphan source; left out of scope.