question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] track_order = True causes `RuntimeError: Can't rename attribute (record is already in B-tree)`

See original GitHub issue

To 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:32 (28 by maintainers)

github_iconTop GitHub Comments

2reactions
1313ecommented, Oct 8, 2019

Just to double check, you have verified this with h5py 2.10, right?

Yes

1reaction
kmuehlbauercommented, Jan 26, 2022

@hmaarrfk No, thats a commit on my fork. I’ve build hdf5 from scratch and applied the fix there to test. Now waiting patiently…

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] track_order = True causes `RuntimeError: Can't rename ...
[BUG] track_order = True causes `RuntimeError: Can't rename attribute (record is already in B-tree)`
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/22 02 ...
Bug :128538 - "sys-apps/coreutils: /bin/hostname should be installed from coreutils not sys-apps/net-tools" status:UNCONFIRMED resolution: severity:enhancement ...
Read more >
Change History — ZODB documentation
Now BTrees raise TypeError if an attempt is made to save a key with comparison inherited from object. (This doesn't apply to old-style...
Read more >
Custom validator throws RuntimeError: :attributes cannot be ...
Call your validator MyUniquenessValidator. UniquenessValidator already exists in activerecord.
Read more >
Transaction locking and row versioning guide - SQL Server
SQL Server documentation uses the term B-tree generally in reference to ... a run-time error by referring to a table that does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found