Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDF5 used in NetCDF-4 is not thread-safe in Julia #450

Closed
danlooo opened this issue Oct 16, 2024 · 1 comment
Closed

HDF5 used in NetCDF-4 is not thread-safe in Julia #450

danlooo opened this issue Oct 16, 2024 · 1 comment

Comments

@danlooo
Copy link
Member

danlooo commented Oct 16, 2024

This issue is to document that accessing HDF5 based data like NetCDF-4 will result in errors and killed processes in a multithreaded context. HDF5 can be compiled in a thread-safe way, e.g. as in PyTables/PyTables#776, but it's not the case in the Julia version. Please add locks to your own code instead. See also JuliaIO/HDF5.jl#835, JuliaIO/HDF5.jl#835 and HDF5/build_tarballs.jl

Example using file sresa1b_ncar_ccsm3-example.nc:

using YAXArrays
using NetCDF
ds = open_dataset("sresa1b_ncar_ccsm3-example.nc")
Threads.@threads for i in 1:Threads.nthreads()
    ds.tas[1, 1, 1]
end

will result in error

ERROR: TaskFailedException

    nested task error: NetCDF error code -43:
        NetCDF: Attribute not found

or in other contexts:

    major: Virtual Object Layer
    minor: Can't open object
  #003: H5VLnative_attr.c line 130 in H5VL__native_attr_open(): can't open attribute
    major: Attribute
    minor: Can't open object
  #004: H5Aint.c line 545 in H5A__open_by_name(): unable to load attribute info from object header
@danlooo
Copy link
Member Author

danlooo commented Oct 16, 2024

Issue is now part ofthe read netcdf4 documentation.

@danlooo danlooo closed this as completed Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant