Repository navigation
Build an anchor to hold a netCDF file open in each batch Dask worker - #747
Open
rhaegar325 wants to merge 3 commits into
Open
rhaegar325 wants to merge 3 commits into
rhaegar325 wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #747 +/- ##
=======================================
+ Coverage 79.7% 79.8% +0.1%
=======================================
Files 41 42 +1
Lines 9173 9199 +26
Branches 1710 1713 +3
=======================================
+ Hits 7315 7345 +30
+ Misses 1524 1522 -2
+ Partials 334 332 -2
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.
Fix #740
Problem
Batch jobs intermittently fail with
RuntimeError: NetCDF: Not a valid ID,raised from
netCDF4.Dataset.__init__(_get_format/_get_vars) after anxarray file-cache miss. A plain rerun usually succeeds. Seen on
direct3D ocean variables with source partitioning (
thkcello,wo,thetao,vo,wmo,so) across piControl, esm-piControl and esm-hist.netCDF-C keeps open files in a process-global table with no lock, and frees the
whole table when the open-file count reaches zero (
del_from_NCList→free_NCListinlibdispatch/nclistmgr.c; unchanged onmain). In a worker,the compute thread opens files while xarray's
CachingFileManager.__del__closes them from another thread without the backend lock. If that close takes
the count to zero during an
nc_open, the new ncid stops resolving.In an isolated netCDF4 test (two threads opening/closing, nothing else open),
10/10 runs crashed; holding one extra file open made 10/10 clean.
Change
executors/nc_anchor.py:NetCDFAnchorPlugin, aWorkerPluginthat holdsa tiny read-only netCDF file in the worker's local directory, so the count
never reaches zero.
is opened, and log
netCDF anchor held on N/N workers.A plugin rather than a preload: the scheduler re-applies it to workers the
nanny restarts, and no config is needed.
This is a workaround for the unsynchronised close, not a fix for it; a lost
update on the non-atomic counter could in principle still hit zero.
Testing
LocalCluster(processes=True): every worker holds the anchor, and stilldoes after
client.restart().dd.Client(and the first CMORiser.(~46k slices) with or without the anchor, so production failure rates are
the real check. The same anchor has been running via
DASK_DISTRIBUTED__WORKER__PRELOADon 1pctCO2, abrupt-4xCO2 and esm-flat10.