Add support for setting the locking behavior when opening file#114
Add support for setting the locking behavior when opening file#114mgeplf wants to merge 5 commits intohighfive-devs:mainfrom
Conversation
* useful when on a shared filesystem that limits the number of locks, and files are only being read
|
Thank you, that looks like a nice feature. You can fix the formatting by running Do you understand why CI says it's not working? Plus you should be a dev now, so you can run CI. Sorry about the delay. |
I'll have a look and try and figure it out - I confess to not having looked at the CI on this repo before.
Neat, thanks. No worries, I'm not in a rush. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
It might be that the lock is held by the process (using the same instance of the shared library HDF5). It would make sense since it's not clear how locking is needed if there's only one HDF5 application running. However, if there's two separate HDF5 applications/processes running they might need locking to prevent corrupting the file. I'm not sure I'm making sense, so once more: To test that the locking is working we might to open the file in one application, then while that's running open the same file from another process; the second one must fail. We don't have CI setup to do this. Therefore, given how trivial the code is; and that we'd be testing HDF5 not HighFive, I think it might be okay to test it once in your application. Then if you say it works, we merge it without the test. |
| /// However, if it's known at access time that one will never have another process writing the file, | ||
| /// the locks can be avoided. | ||
| /// | ||
| /// See more in https://support.hdfgroup.org/documentation/hdf5/latest/_file_lock.html |
There was a problem hiding this comment.
We've never added links to HDF5 documentation, because the URLs change almost weekly. Seems like good information though.
Yeah, I was hoping to use the behavior that hdf5 has an internal cache, and opening the file in two different modes makes it fail. Unfortunately, this behavior doesn't seem to be true in all cases, hence the failure.
Ok, that makes my life easier - I'll remove some of the tests, and see if it runs. I've tested it locally, I will attach an Sorry about the delay, been busy - might also be a couple days before I get around to the above. |
With with
fapl.add(HighFive::FileLocking(true, false));one gets (on linux):and
fapl.add(HighFive::FileLocking(false, false));: