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

test_reopen fails for forthcoming libhdf5-1.14.4 #2403

Closed
ajelenak opened this issue Apr 3, 2024 · 6 comments
Closed

test_reopen fails for forthcoming libhdf5-1.14.4 #2403

ajelenak opened this issue Apr 3, 2024 · 6 comments
Milestone

Comments

@ajelenak
Copy link
Contributor

ajelenak commented Apr 3, 2024

Just fyi... These lines in the test_reopen of the test_file.py cause OSError with the code of the future libhdf5 1.14.4 release:

with h5py.File(fname, mode="r", locking='best-effort') as h5f_read:
pass

The change in behavior is likely caused by this (text from RELEASE.txt):

    - Fixed H5Fget_access_plist so that it returns the file locking
      settings for a file

      When H5Fget_access_plist (and the internal H5F_get_access_plist)
      is called on a file, the returned File Access Property List has
      the library's default file locking settings rather than any
      settings set for the file. This causes two problems:

        - Opening an HDF5 file through an external link using H5Gopen,
          H5Dopen, etc. with H5P_DEFAULT for the Dataset/Group/etc.
          Access Property List will cause the external file to be opened
          with the library's default file locking settings rather than
          inheriting them from the parent file. This can be surprising
          when a file is opened with file locking disabled, but its
          external files are opened with file locking enabled.

        - An application cannot make use of the H5Pset_elink_fapl
          function to match file locking settings between an external
          file and its parent file without knowing the correct setting
          ahead of time, as calling H5Fget_access_plist on the parent
          file will not return the correct settings.

      This has been fixed by copying a file's file locking settings
      into the newly-created File Access Property List in H5F_get_access_plist.

      This fix partially addresses GitHub issue #4011
@aragilar
Copy link
Member

aragilar commented Apr 5, 2024

h5py/h5py/_hl/files.py

Lines 155 to 156 in 066cad1

elif locking == "best-effort":
plist.set_file_locking(True, ignore_when_disabled=True)
and hence

h5py/h5py/h5p.pyx

Lines 1518 to 1525 in 066cad1

def set_file_locking(self, bint use_file_locking, bint ignore_when_disabled):
""" (BOOL use_file_locking, BOOL ignore_when_disabled)
Set HDF5 file locking behavior.
Warning: This setting is overridden by the HDF5_USE_FILE_LOCKING environment variable.
"""
H5Pset_file_locking(
self.id, <hbool_t>use_file_locking, <hbool_t>ignore_when_disabled)
are where this logic is handled. I'm not sure what H5Pset_file_locking is doing with ignore_when_disabled=False, as that's what's different to the other cases.

@ajelenak
Copy link
Contributor Author

ajelenak commented Apr 5, 2024

Should there be a note in the documentation about the change for the best-effort option? Someone may have used it and now it will throw an error.

@takluyver
Copy link
Member

takluyver commented Apr 5, 2024

What does the error from this look like? Is it only when reopening an already-open file, or does best-effort always fail now?

@ajelenak
Copy link
Contributor Author

ajelenak commented Apr 5, 2024

The error text is: file locking 'ignore disabled locks' flag values don't match.

Is it only when reopening an already-open file

Yes. I reported in the context of this test.

@takluyver
Copy link
Member

OK, so probably all that's needed is tweaking the test itself? I doubt reopening the same file with different options comes up often enough in the wild to be a big deal.

@takluyver
Copy link
Member

Fixed by #2406, I believe.

@takluyver takluyver added this to the 3.11 milestone Apr 9, 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

3 participants