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
Fix .b2z double-open corruption caused by GC-triggered repacking
Opening a .b2z store in append mode a second time (in a new process) was
failing with "blosc2_schunk_open_offset returned NULL" because the first
open had silently overwritten the archive with a near-empty ZIP file.
Two root causes were identified and fixed:
1. Probe store in _open_treestore_root_object() called close() on a
temporary TreeStore used only to read the manifest. This triggered
to_b2z() and repacked the archive before the real open started.
Fix: added DictStore.discard() (cleanup without repack) and switched
the probe store to call discard() instead of close().
2. CTable.__del__ (GC path) called storage.close() which chained into
TreeStore.close() → to_b2z(). With nothing modified, the temp dir
could be partially torn down, producing a corrupt archive.
Fix: DictStore gains _closed and _modified flags; __del__ now calls
discard() when _modified is False (no writes via __setitem__/
__delitem__), and close() otherwise. CTable.__del__ is changed to
call storage.discard() directly. FileTableStorage.discard() and
TableStorage.discard() added to complete the delegation chain.
3. TreeStore subtree views (created via __dict__.update from the parent)
shared the parent's _temp_dir_obj. GC of a subtree could destroy the
parent's temp dir. Fix: subtrees now set _closed=True immediately
after copying the parent's __dict__.
The contract is:
- Explicit close() / with block → always repacks (user intent)
- GC __del__ with no store-level writes → discard() (no repack, safe)
- GC __del__ with __setitem__/__delitem__ writes → close() (repack)
Add two regression tests: one at the DictStore layer and one for the
full indexed-CTable-in-.b2z scenario that triggered the original report.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments