CAGRA-ACE: Make Disk Workspaces Transactional and Non-destructive - #2336
CAGRA-ACE: Make Disk Workspaces Transactional and Non-destructive#2336julianmi wants to merge 6 commits into
Conversation
dantegd
left a comment
There was a problem hiding this comment.
Good PR!
Had one correctness comment only, and a couple of questions besides the review one:
- Could we mirror the new build_dir contract in c/include/cuvs/neighbors/cagra.h? That public API exposes the same ACE parameters, but its documentation still doesn’t mention that named artifacts must be absent or that simultaneous builds require distinct directories.
- Wasn't sure what is intended transaction boundary here? A public hnsw::build using ACE first creates and commits the four CAGRA artifacts, then writes hnsw_index.bin into the same build_dir. The latter is still opened with truncation in hnsw.hpp. Is this PR’s non-destructive contract intended to cover only the CAGRA stage, or the complete HNSW ACE build seen by the caller? If it is CAGRA only, could we state that scope explicitly?
| // Open file | ||
| file_descriptor fd(path, O_CREAT | O_RDWR | O_TRUNC, 0644); | ||
| const int flags = O_CREAT | O_RDWR | (exclusive ? O_EXCL : O_TRUNC); | ||
| file_descriptor fd(path, flags, 0644); |
There was a problem hiding this comment.
Should we make the exclusive create branch unlink path if anything after this successful open throws? With exclusive=true, open creates the file here, but posix_fallocate or write can still fail before create_numpy_file returns. The caller therefore never reaches mark_artifact_created, so rollback leaves a partial ACE artifact that blocks the next retry.
What do you think about guarding the newly created path inside this helper until the function succeeds, while preserving the current non-exclusive behavior?
There was a problem hiding this comment.
Good catch, thanks. After an exclusive open succeeds, create_numpy_file now closes and unlinks the newly created path if preallocation, seek, or header writing throws. The non-exclusive truncating behavior is unchanged. I've also added a regression test.
9c7bc0a to
62fc742
Compare
Agreed.
Yes, I think we should extend it to HNSW ACE builds as well. I've added an |
Make ACE disk workspaces non-destructive and failure-safe.
build_dircontract: named artifacts must be absent and concurrent builds need separate directories.hnsw_index.binonly when that name is absent. A completed CAGRA stage remains if later HNSW conversion fails.