H5Lcreate_external fails but the link is still created


#1

libhdf5: 1.12.1
file: https://gitlab.esrf.fr/bliss/bliss/uploads/2f4f19f00e9035b373ac4c0f526b1930/master.h5

When creating an external link with H5Lcreate_external in the file above, the operation fails but the links is still created.

Calling h5repack solves the issue but I want to know what is wrong with the file and what could have caused it.

Reproduce the issue

#include "hdf5.h"
#include <stdio.h>
#include <stdlib.h>

#define FILE        "master.h5"
#define EXT_FILE    "ext.h5"
#define EXT_PATH    "/2.1"
#define LINK_NAME   "link"


int main(int argc, char *argv[])
{
    hid_t file, dset;
    herr_t status;

    printf("Open file: %s\n", FILE);
    file = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);

    printf("Create link: %s\n", LINK_NAME);
    status = H5Lcreate_external(EXT_FILE, EXT_PATH, file, LINK_NAME,
            H5P_DEFAULT, H5P_DEFAULT);

    printf("Finished.\n");
    status = H5Fclose(file);
    return 0;
}

Traceback

HDF5-DIAG: Error detected in HDF5 (1.10.4) thread 140737350002496:
  #000: ../../../src/H5Lexternal.c line 383 in H5Lcreate_external(): unable to create link
    major: Links
    minor: Unable to initialize object
  #001: ../../../src/H5L.c line 2070 in H5L__create_ud(): unable to register new name for object
    major: Links
    minor: Unable to initialize object
  #002: ../../../src/H5L.c line 1813 in H5L__create_real(): can't insert link
    major: Links
    minor: Unable to insert object
  #003: ../../../src/H5Gtraverse.c line 851 in H5G_traverse(): internal path traversal failed
    major: Symbol table
    minor: Object not found
  #004: ../../../src/H5Gtraverse.c line 627 in H5G__traverse_real(): traversal operator failed
    major: Symbol table
    minor: Callback failed
  #005: ../../../src/H5L.c line 1658 in H5L__link_cb(): unable to create new link for object
    major: Links
    minor: Unable to initialize object
  #006: ../../../src/H5Gobj.c line 596 in H5G_obj_insert(): unable to insert link into dense storage
    major: Symbol table
    minor: Unable to insert object
  #007: ../../../src/H5Gdense.c line 456 in H5G__dense_insert(): unable to insert record into v2 B-tree
    major: Symbol table
    minor: Unable to insert object
  #008: ../../../src/H5B2.c line 292 in H5B2_insert(): unable to insert record into B-tree
    major: B-Tree node
    minor: Unable to insert object
  #009: ../../../src/H5B2int.c line 1471 in H5B2__insert(): unable to insert record into B-tree internal node
    major: B-Tree node
    minor: Unable to insert object
  #010: ../../../src/H5B2internal.c line 475 in H5B2__insert_internal(): unable to insert record into B-tree internal node
    major: B-Tree node
    minor: Unable to insert object
  #011: ../../../src/H5B2internal.c line 479 in H5B2__insert_internal(): unable to insert record into B-tree leaf node
    major: B-Tree node
    minor: Unable to insert object
  #012: ../../../src/H5B2leaf.c line 367 in H5B2__insert_leaf(): unable to protect B-tree leaf node
    major: B-Tree node
    minor: Unable to protect metadata
  #013: ../../../src/H5B2leaf.c line 208 in H5B2__protect_leaf(): unable to protect B-tree leaf node
    major: B-Tree node
    minor: Unable to protect metadata
  #014: ../../../src/H5AC.c line 1625 in H5AC_protect(): H5C_protect() failed
    major: Object cache
    minor: Unable to protect metadata
  #015: ../../../src/H5C.c line 2362 in H5C_protect(): can't load entry
    major: Object cache
    minor: Unable to load metadata into cache
  #016: ../../../src/H5C.c line 6621 in H5C_load_entry(): Can't read image*
    major: Object cache
    minor: Read failed
  #017: ../../../src/H5Fio.c line 118 in H5F_block_read(): read through page buffer failed
    major: Low-level I/O
    minor: Read failed
  #018: ../../../src/H5PB.c line 732 in H5PB_read(): read through metadata accumulator failed
    major: Page Buffering
    minor: Read failed
  #019: ../../../src/H5Faccum.c line 211 in H5F__accum_read(): driver read request failed
    major: Low-level I/O
    minor: Read failed
  #020: ../../../src/H5FDint.c line 200 in H5FD_read(): addr overflow, addr = 227480, size = 512, eoa = 227480
    major: Invalid arguments to routine
    minor: Address overflowed
Finished.

#2

Why does it say 1.10.4 in the error output?


#3

Sorry got the libhdf5 version through h5py. It is 1.10.4 indeed.


#4

This is the traceback for 1.12.2

HDF5-DIAG: Error detected in HDF5 (1.12.2) thread 0:
  #000: /users/denolf/dev/hdf5/src/H5Lexternal.c line 404 in H5Lcreate_external(): unable to create external link
    major: Links
    minor: Unable to initialize object
  #001: /users/denolf/dev/hdf5/src/H5VLcallback.c line 4739 in H5VL_link_create(): link create failed
    major: Virtual Object Layer
    minor: Unable to create file
  #002: /users/denolf/dev/hdf5/src/H5VLcallback.c line 4684 in H5VL__link_create(): link create failed
    major: Virtual Object Layer
    minor: Unable to create file
  #003: /users/denolf/dev/hdf5/src/H5VLnative_link.c line 115 in H5VL__native_link_create(): unable to create link
    major: Links
    minor: Unable to initialize object
  #004: /users/denolf/dev/hdf5/src/H5L.c line 2185 in H5L__create_ud(): unable to register new name for object
    major: Links
    minor: Unable to initialize object
  #005: /users/denolf/dev/hdf5/src/H5L.c line 2009 in H5L__create_real(): can't insert link
    major: Links
    minor: Unable to insert object
  #006: /users/denolf/dev/hdf5/src/H5Gtraverse.c line 837 in H5G_traverse(): internal path traversal failed
    major: Symbol table
    minor: Object not found
  #007: /users/denolf/dev/hdf5/src/H5Gtraverse.c line 613 in H5G__traverse_real(): traversal operator failed
    major: Symbol table
    minor: Callback failed
  #008: /users/denolf/dev/hdf5/src/H5L.c line 1855 in H5L__link_cb(): unable to create new link for object
    major: Links
    minor: Unable to initialize object
  #009: /users/denolf/dev/hdf5/src/H5Gobj.c line 571 in H5G_obj_insert(): unable to insert link into dense storage
    major: Symbol table
    minor: Unable to insert object
  #010: /users/denolf/dev/hdf5/src/H5Gdense.c line 425 in H5G__dense_insert(): unable to insert record into v2 B-tree
    major: Symbol table
    minor: Unable to insert object
  #011: /users/denolf/dev/hdf5/src/H5B2.c line 281 in H5B2_insert(): unable to insert record into B-tree
    major: B-Tree node
    minor: Unable to insert object
  #012: /users/denolf/dev/hdf5/src/H5B2int.c line 1588 in H5B2__insert(): unable to insert record into B-tree internal node
    major: B-Tree node
    minor: Unable to insert object
  #013: /users/denolf/dev/hdf5/src/H5B2internal.c line 482 in H5B2__insert_internal(): unable to insert record into B-tree internal node
    major: B-Tree node
    minor: Unable to insert object
  #014: /users/denolf/dev/hdf5/src/H5B2internal.c line 486 in H5B2__insert_internal(): unable to insert record into B-tree leaf node
    major: B-Tree node
    minor: Unable to insert object
  #015: /users/denolf/dev/hdf5/src/H5B2leaf.c line 355 in H5B2__insert_leaf(): unable to protect B-tree leaf node
    major: B-Tree node
    minor: Unable to protect metadata
  #016: /users/denolf/dev/hdf5/src/H5B2leaf.c line 197 in H5B2__protect_leaf(): unable to protect B-tree leaf node
    major: B-Tree node
    minor: Unable to protect metadata
  #017: /users/denolf/dev/hdf5/src/H5AC.c line 1426 in H5AC_protect(): H5C_protect() failed
    major: Object cache
    minor: Unable to protect metadata
  #018: /users/denolf/dev/hdf5/src/H5C.c line 2370 in H5C_protect(): can't load entry
    major: Object cache
    minor: Unable to load metadata into cache
  #019: /users/denolf/dev/hdf5/src/H5C.c line 7209 in H5C__load_entry(): Can't read image*
    major: Object cache
    minor: Read failed
  #020: /users/denolf/dev/hdf5/src/H5Fio.c line 148 in H5F_block_read(): read through page buffer failed
    major: Low-level I/O
    minor: Read failed
  #021: /users/denolf/dev/hdf5/src/H5PB.c line 721 in H5PB_read(): read through metadata accumulator failed
    major: Page Buffering
    minor: Read failed
  #022: /users/denolf/dev/hdf5/src/H5Faccum.c line 202 in H5F__accum_read(): driver read request failed
    major: Low-level I/O
    minor: Read failed
  #023: /users/denolf/dev/hdf5/src/H5FDint.c line 182 in H5FD_read(): addr overflow, addr = 227480, size = 512, eoa = 227480
    major: Invalid arguments to routine
    minor: Address overflowed
Finished.

#5

How does

ext.h5

file look like?
Can you share it as well?


#6

This is just a file with 1 group. It doesn’t affect the issue

ext.h5 (1.8 KB)


#7

When you say h5repack fixes the issue, do you mean that if you repack master.h5 you can then create the external link successfully?

Assuming so, it looks at first glance like the program that created the file got shut down before the file could be fully flushed/extended. The b-tree code is trying to read a b-tree node at a file address that starts at the end of the file (i.e. just past the end of the file).

Do you have a program that can repeatably create a master.h5 that exhibits the problem?


#8

When you say h5repack fixes the issue, do you mean that if you repack master.h5 you can then create the external link successfully?

Indeed.

Well in fact you can create a link even without h5repack. It’s just that upon creating the link (run the sample code I provided) it raises an error even though the link is created (inspect the file after the failure, you will see the link is created).

Do you have a program that can repeatably create a master.h5 that exhibits the problem?

These files are created by the acquisition control systems running on our beamlines writing over GPFS or NFS. So I’m afraid I cannot reproduce the incident.

The b-tree code is trying to read a b-tree node at a file address that starts at the end of the file (i.e. just past the end of the file).

File corruption is something that happens occasionally. So this is just another iteration of that. It is a rather peculiar case (raising an exception even though the operation succeeds) which made me think it was a libhdf5 bug of sorts.

Thanks for looking into this!


#9

HDF5 can’t guarantee anything for writing over GPFS/NFS.