Repository navigation
Disable automatic GC while a remote asset is open, to avoid a deadlock - #1967
Draft
CodyCBakerPhD wants to merge 1 commit into
Draft
CodyCBakerPhD wants to merge 1 commit into
CodyCBakerPhD wants to merge 1 commit into
Conversation
h5py holds its global lock while it reads from a Python file object, and a read of a RemoteReadableAsset waits for fsspec's IO thread to fetch the data. If a garbage collection runs in that thread meanwhile, the finalizer of an unreferenced object closing an HDF5 file (e.g., hdmf's HDMFIO.__del__ -> HDF5IO.close() -> h5py's File.close()) waits for the same lock, and neither thread can proceed. The aiohttp timeouts cannot end this, as the event loop thread itself is blocked. This is the hang of test_nwb2asset_remote_asset (#1450), and it made test_reextract_metadata time out in the lowest-deps CI job of #1955. RemoteReadableAsset.open() now wraps fsspec's file object in a _GCPausedFile, which disables automatic garbage collection while any such file is open (and restores the previous state once all are closed). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qn5WBSiQgoZoL4fytF6nEr
CodyCBakerPhD
pushed a commit
that referenced
this pull request
Oct 16, 2026
…talad-fuse-readable Port the fix for the deadlock that made test_reextract_metadata time out in the lowest-deps job.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1967 +/- ##
==========================================
+ Coverage 90.76% 90.88% +0.12%
==========================================
Files 92 93 +1
Lines 14159 14238 +79
==========================================
+ Hits 12851 12940 +89
+ Misses 1308 1298 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Reading a remote NWB asset through
RemoteReadableAssetcan hang forever: a deadlock between h5py's global lock and garbage collection in fsspec's IO thread. This is the cause of the timeouts in #1450, and it madetest_reextract_metadatatime out in thelowest-depsjob of #1955.The deadlock
RemoteReadableAssetwaits for fsspec's IO thread to fetch the data.HDMFIO.__del__callsHDF5IO.close(), which calls h5py'sFile.close(), which waits for h5py's lock.The main thread's stack is the one in #1450 and in the CI failure of #1955:
h5py.File()→ fsspec'sreadinto()→sync()→Event.wait().Whether it happens depends on when a collection happens to run, so it comes and goes with unrelated changes. On #1955 it happened on every run of the
lowest-depsjob, and never on master.Changes
RemoteReadableAsset.open()wraps fsspec's file object in a new_GCPausedFile.Tests
test_gc_paused_fileandtest_gc_paused_file_gc_disabled(newdandi/tests/test_misctypes.py) cover nesting, closing, dropping an unclosed file, and GC being disabled beforehand.test_asset_as_readable_open_pauses_gcchecks that a remote asset opened from the test archive pauses GC.lowest-depsversions from CI (hdmf 4.1.0, h5py 3.16.0, fsspec 2022.11.0):test_reextract_metadatapasses, also with the latest versions.test_nwb2asset_remote_assetnow gets past the read. It still fails, on its expected metadata (strain), so itsxfailis left as is.🤖 Generated with Claude Code
https://claude.ai/code/session_01Qn5WBSiQgoZoL4fytF6nEr
Generated by Claude Code