fix: check H5AD lock before overwrite - #2569
Closed
stanbot8 wants to merge 1 commit into
Closed
Conversation
stanbot8
force-pushed
the
agent/issue-522-safe-h5ad-overwrite
branch
from
July 23, 2026 20:02
f37debe to
8c23e3e
Compare
stanbot8
marked this pull request as ready for review
July 23, 2026 20:04
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2569 +/- ##
==========================================
- Coverage 87.81% 85.87% -1.95%
==========================================
Files 49 49
Lines 7799 7802 +3
==========================================
- Hits 6849 6700 -149
- Misses 950 1102 +152
|
Author
|
Superseded by #2570. The replacement writes a complete temporary file before it replaces the target. This design removes the reader-open race that remains in this preflight check. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HDF5 can truncate a live H5AD target before it reports a lock failure (h5py issue 1864, HDF5 issue HDFFV-11230). This change opens an existing HDF5 target with
r+before the truncate-mode open. An active reader blocks the overwrite before truncation. Closes #522.Design
The check changes less code. It does not need a temporary copy.
The implementation changes
src/anndata/_io/h5ad.py. The design follows the reported truncation reproducer, the requested overwrite behavior, and the HDF5 lock analysis.Limitations
Tests
The benchmark and codespell checks passed.
Commands
pytest -q tests/test_readwrite.py -k 'test_write_h5ad_open_elsewhere'