[BUG] track_order = True causes `RuntimeError: Can't rename attribute (record is already in B-tree)`
See original GitHub issueTo assist reproducing bugs, please include the following:
- Operating System: Windows/Linux Ubuntu/MacOS-X
- Python version: 3.5+
- Where Python was acquired: Anaconda
- h5py version: 2.9.0+
- HDF5 version: 1.10.4
- The full traceback/stack trace shown (if it appears):
Traceback (most recent call last):
File "h5py_bug.py", line 9, in <module>
file.attrs[str(i)] = i
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/home/evandervelden/anaconda3/envs/py3/lib/python3.7/site-packages/h5py/_hl/attrs.py", line 100, in __setitem__
self.create(name, data=value)
File "/home/evandervelden/anaconda3/envs/py3/lib/python3.7/site-packages/h5py/_hl/attrs.py", line 217, in create
h5a.rename(self._id, self._e(tempname), self._e(name))
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5a.pyx", line 118, in h5py.h5a.rename
RuntimeError: Can't rename attribute (record is already in B-tree)
This bug has been reported quite a few times already (e.g., #1180, #1185 and others probably), but all of them are reporting that the bug solely appears when building h5py
against HDF5 1.10.5.
However, I can cause that bug to appear perfectly fine in HDF5 1.10.4 (and probably other versions as well), as long as the track_order
parameter can be set to True (which was added in h5py
2.9.0).
The following code will reproduce this error on Python 3.5/3.6/3.7; on Windows/Linux Ubuntu/MacOS-X:
import h5py
h5py.get_config().track_order = True
with h5py.File('test.hdf5', 'a') as file:
for i in range(20):
print(i)
file.attrs[str(i)] = i
After setting an attribute 8 times, setting the 9th will raise the error as shown above. It does not matter how the file was opened; what the attributes are; what their types are; what is already contained in the HDF5-file; and so on. It also does not matter how many attributes are set at once; setting the 9th will always trigger the error. For example, the following will do the exact same thing:
import h5py
h5py.get_config().track_order = True
for i in range(20):
with h5py.File('test.hdf5', 'a') as file:
print(i)
file.attrs[str(i)] = i
Attempting to execute either of these code snippets twice in a row (of course making sure that mode='a'
), will cause the error immediately upon setting the first attribute.
Exception to the above is that when the code snippet is executed on an already existing HDF5-file that was created with track_order = False
, it does not raise the error.
However, obviously, it will not keep track of the insertion order of any new attributes either.
Hopefully this helps.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:32 (28 by maintainers)
Yes
@hmaarrfk No, thats a commit on my fork. I’ve build hdf5 from scratch and applied the fix there to test. Now waiting patiently…