Files
clawhdf5/crates
osobhandClaude Opus 5.5 21f104bb77 facade: File::open_swmr, Dataset::refresh and bounded retries for live SWMR files
Range-read milestone M5 (docs/design/swmr.md): read a file a libhdf5
SWMR writer (h5py f.swmr_mode = True) is still appending to, as h5py's
File(path, 'r', swmr=True) does.

- File::open_swmr / open_storage_swmr: the file is read through the new
  FileStorage (pread / seek_read, never mapped, len() the current length),
  reads are bounded by the length at each read, and the chunk cache is not
  used (a cached index hides new chunks; a cached edge chunk reads as fill
  where the writer has since written). A file open for writing without
  SWMR is refused with Error::Locked, as libhdf5 refuses it.
- Dataset::refresh re-reads the object header (H5Drefresh).
- Operations that fail with an error a racing write can cause (every
  format error but a wrong path/selection, an unsupported feature or a bad
  argument) are run again, up to 100 attempts (libhdf5's default metadata
  read attempts for SWMR readers), 1 us doubling to 10 ms apart; nested
  operations retry as a whole. swmr_retries() counts them,
  swmr_writer_active() re-reads the superblock flags.

Tests: FileStorage growth and retry policy (unit); the mid-write copy
through open_swmr; a storage that garbles reads (retried, given up after
the attempts, never returned); and a live h5py writer appending to
Extensible-Array (plain and gzip) and v2-B-tree datasets for 2500 steps
while two Rust reader threads and h5py's SWMR reader check every value,
then the closed file read equal to h5py. Leaving the chunk cache on in
live mode fails the live test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-27 06:49:04 -05:00
..