Skip to content

Research notes / Scientific data storage

HDF5 dependencies: missing sources and truncated raw data

Published / Updated / Measured API behavior

A byte-perfect copy of an HDF5 virtual dataset file is not necessarily a complete copy of its data. In our experiment, missing sources returned zeros without a read error. A search-path override also changed the returned values while the virtual file and its two neighboring source files retained their original hashes. Saved region references can also become readable again after shrinking and re-extending a dataset, without recovering their original values. A separate external-raw-file experiment below shows a different failure mode: truncation can change an integer without a read error, even with a nonzero fill sentinel.

On this page9 sections

The file stores a mapping, not necessarily the values

An HDF5 virtual dataset (VDS) joins selections from other datasets into one array. A program can slice it like an ordinary dataset, even when its sources occupy separate files. Sources can be declared before they exist. This is useful for assembling independently produced arrays without first duplicating their contents. [1]

HDF5 explicitly permits missing sources to appear as fill values. The default fill value is zero, interpreted for the datatype; an application can choose another value. This behavior is a feature, not evidence of a library defect. The mistake is assigning a stronger meaning to a successful read than the mapping promises. [2] [3]

Why keep a virtual view instead of a copy?

ArrayBridge (Xing et al., ICDE 2018) used VDS to expose independently written files as one array and to reconstruct versions from shared data. Its coordinator combined mapping records before creating the view; repeatedly rebuilding accumulated mappings incurred quadratic mapping work. This is an interoperability and write-organization benefit, not a guarantee that one file contains an archive. [5]

The evaluation used SciDB 15.12 on NERSC Edison with Lustre. Its performance measurements belong to that configuration; our small fixture does not reproduce them. Our archival inference: removing data duplication makes preservation of the referenced data more important, not less.

A mapping includes source and destination selections, not just filenames. A hyperslab specifies logical array regions; it is not an on-disk chunk. Record the selections as well as the identities of source objects. Our raw fixture logs source names and paths, while its fixed row selections are specified in the downloadable harness.

Eight cases, with the virtual file unchanged

We mapped a.h5:/data and b.h5:/data into a fixed array of two rows and three columns. The first source held [11,12,13]; the second normally held [21,22,23]. These are dimensionless test integers, not instrument readings. Two VDS objects used the same mapping with different fill policies.

First repetition of three identical outcome sets. Values shown are the second row. Every final read succeeded and every VDS file hash matched its own pre-change baseline.
CaseDefault fillFill = -999Neighboring source hashes match?
Both sources present[21,22,23][21,22,23]Yes
Second source file missing[0,0,0][-999,-999,-999]No
Second dataset missing[0,0,0][-999,-999,-999]No
Second source replaced[91,92,93][91,92,93]No
Second source contains real zeros[0,0,0][0,0,0]Yes
Only VDS relocated[0,0,0][-999,-999,-999]No
VDS and both sources relocated[21,22,23][21,22,23]Yes
Search prefix selects replacement[91,92,93][91,92,93]Yes

Removing the second file and removing only its expected /data dataset produced the same fill output. With default fill, that output was indistinguishable from the separate control containing genuine zeros. All arrays still reported shape (2,3). When only the VDS was relocated, both rows became fill values; relocating both sources with it preserved the original values.

The explicit sentinel made absence visible in these cases. It did not expose a substituted, structurally compatible source: both fill policies returned [91,92,93]. A recognizable missing-value code is useful, but it is not source authentication.

Even the neighboring source hashes can pass

The prefix-override case left view.h5, a.h5 and b.h5 untouched. We created a different b.h5 in another private directory and set HDF5_VDS_PREFIX for the new reader process. The reader obtained replacement values, even though a manifest checker examining only the original files beside the VDS would accept all three.

This matches the documented lookup order: for relative source names, environment prefixes are tried before a dataset-access prefix and the VDS file's directory; further fallback can use the relative name itself. Resolution behavior is part of the read environment, not merely the stored filename. [3]

Our inference: a reproducible archive needs both dependency identity and controlled resolution. The hashes did not fail to detect changed bytes. They correctly identified files that were no longer the complete set of files governing this read. This is a path-selection problem, not a cryptographic collision.

External raw files: truncation can change a number silently

HDF5 has another dependency mechanism: external raw storage maps byte ranges of non-HDF5 files into a contiguous dataset. It is neither a virtual dataset nor an external link to another HDF5 object. The dataset guide specifies zero-valued bytes beyond an external file's end. The pinned 1.14.6 implementation handles EOF by zeroing the remaining read buffer; failure to open the file follows an error path. [External storage guide] [Implementation]

Our test starts with four signed 32-bit integers: [16909060,287454020,555885348,825373492]. Their 16 payload bytes follow an eight-byte header in payload.bin. Two datasets point to that same range, one with default fill and one with fillvalue=-999. Writers close before any change, and fresh processes read both arrays before and after it.

Little-endian results from repetition 1 of 3 on h5py 3.15.0 / HDF5 1.14.6. Both fill policies returned the same values or error. All metadata-file hashes stayed unchanged.
Raw-file conditionFile bytesReturned integers
Intact control24[16909060,287454020,555885348,825373492]
Cut after two integers16[16909060,287454020,0,0]
Cut inside second integer14[16909060,13124,0,0]
Empty file0[0,0,0,0]
File absentAbsentOSError
Same-size replacement24[1633771873,1633771873,1633771873,1633771873]
Full-length stored zeros24[0,0,0,0]

The fill sentinel does not describe these missing bytes

Keeping six payload bytes left only two bytes of the second integer. Its little-endian bytes changed from 44 33 22 11 to 44 33 00 00, so 287454020 became 13124. With big-endian storage, the same two-byte loss produced 287440896 instead. Neither value was zero or -999. Detecting zero-valued elements alone would miss this partially changed number.

The configured sentinel remained -999 in the metadata, but the short and empty raw files produced zero bytes rather than sentinel elements. This differs from the missing-source VDS behavior above. The empty file and a full-length file containing actual zeros returned identical arrays. Removing the raw file entirely raised an error. These controls show why a missing-file test alone does not cover truncated-file recovery.

Use the prefix for the mechanism being read

External raw storage uses HDF5_EXTFILE_PREFIX, not the HDF5_EXT_PREFIX used for external links; VDS uses HDF5_VDS_PREFIX. With the default raw-file access settings, relative names resolve from the process working directory. The raw-file prefix can instead use ${ORIGIN} for a location relative to the containing HDF5 file. The environment setting overrides the dataset-access prefix when the dataset is opened. [Raw-file lookup] [External links]

The downloadable EOF harness clears HDF5_EXTFILE_PREFIX for each fresh reader. Clearing only the external-link setting would leave a raw-file override active. A baseline value check must pass before a truncation case is interpreted.

Validate the mapped range, then its identity

The aligned-truncation case retained a 16-byte file, equal to the dataset's nbytes, yet only eight payload bytes remained after the header. For this fixed mapping, all required bytes end at offset + payload size = 8 + 16 = 24. Comparing file length with nbytes alone accepts the wrong boundary. The same-size replacement passed the 24-byte boundary check but returned different values; range coverage cannot establish content identity.

Our preservation recommendation: inventory Dataset.external as well as VDS mappings, retain segment order and offsets, verify the required ranges against a stable source generation, and bind their contents to trusted digests. [h5py API] For growing or multi-segment datasets, derive the required range from the intended extent; a reserved segment's maximum size is not automatically a promise that every byte was written. An unchanged metadata file and a successful array read are insufficient checks.

Reproduction: harness, observation checks, pinned requirements, and raw JSON with hashes and complete arrays. Seven conditions, two byte orders and three repetitions yielded 42 fixtures and 84 post-change array reads, plus 84 successful baseline reads. Repetitions agreed; these are controlled examples, not independent estimates of failure frequency.

python3 -m venv .venv
.venv/bin/pip install --only-binary=:all: -r hdf5-external-eof-requirements.txt
.venv/bin/python hdf5-external-eof.py --repetitions 3 --output observations.json

Python 3.12.3, NumPy 2.3.3, Linux x86_64, sec2 driver and v110 format bounds. The runner uses private temporary files, one finite segment, fixed int32 arrays, a controlled working directory and unset external-prefix overrides. It does not test concurrent writers, power loss, other datatypes or general dependency discovery. This reproduces documented behavior, not a newly discovered HDF5 defect. Original code and observations are CC0-1.0.

A region reference can become valid again without recovering its data

A saved region reference selects a dataset region; it does not preserve its former values. In our closed-file controls, shrinking a dataset made the selection invalid. Restoring its extent made the same stored reference readable again, but it returned fill or newly written values. This is a separate preservation problem from missing external files: all objects can remain inside one readable HDF5 file.

h5py describes region references as dataset references with selections, and a reference's truth value as a nullness check. Its resize contract says that shrinking discards removed data. The exercised binding calls the legacy reference API; the pinned HDF5 implementation encodes object identity and a selection, not historical payload. [Reference contract] [Resize contract] [Binding] [Native implementation]

Each fixture initially contains twelve dimensionless int32 values, 100 through 111, with four-element chunks and Fletcher32 enabled. A persisted hyperslab selects coordinates 8 through 11; a second reference selects points 8, 10 and 11. Writers close before fresh reader processes reopen each baseline and changed file. Both HDF5 1.14.2 and 1.14.6 produced the same semantic outcomes.

Nine deterministic controls per build. Hyperslab results shown; point-selection results are retained in the evidence. Original selected values are [108,109,110,111]. Reference storage bytes and within-file target identity stayed unchanged in every case.
OperationSelection valid?Read resultSelected chunk allocated?
Unchanged controlYes[108,109,110,111]Yes
Overwrite selected valuesYes[208,209,210,211]Yes
Append beyond selectionYes[108,109,110,111]Yes
Rename and replace old pathnameYes[108,109,110,111]Yes
Shrink from 12 to 8NoRead errorNo
Shrink, re-extend, leave fillYes[-999,-999,-999,-999]No
Shrink, re-extend, write new valuesYes[208,209,210,211]Yes
Shrink, re-extend, rewrite originalsYes[108,109,110,111]Yes
Damage one raw payload byteYesRead errorYes

Readable coordinates, current checksums and historical values differ

After shrinking to eight elements, both references remained non-null and their dataset could still be opened, but the selected reads failed. Re-extension to twelve restored validity. Without a tail write, both selections returned -999 and the selected chunk was unallocated. This fill-only read is not a payload checksum pass: Fletcher32 was configured, but there was no stored selected chunk to verify.

Writing a new tail instead returned [208,209,210,211] through the old hyperslab reference. The deliberately damaged-chunk control failed to read, so successful legal rewrites do not imply a disabled corruption check. Rewriting the original values restored numerical equality, but not evidence that the values had never been removed. The fixture's generation attribute records its scripted operations; it is not an authenticated HDF5 version counter.

Append and rename controls preserved the selected values. After append, the reconstructed dataspace extent was sixteen, not its creation-time twelve. After rename, the reference still selected the original dataset even though a replacement occupied its old pathname. Neither the current extent nor a pathname alone identifies a historical data version. HDF5 also requires reacquiring dataspace handles after resizing; these readers use fresh handles. [Extent contract]

Preservation inference: decide whether an archive promises a live selection, numerical equality or a particular measurement history. Bind the intended version, selection and interpretation to a trusted manifest or immutable snapshot, and preserve its values. This connects dependency completeness here with checksum scope and intended identity: restored access is a weaker check than restored scientific content.

Reproduce the reference-lifetime controls

The offline evidence bundle contains 36 synthetic HDF5 files, both raw observation reports, code, pinned requirements, sources and tests. The machine-readable summary and file hashes identify the published evidence. After extraction, run in the bundle directory:

python3 -m venv .venv
.venv/bin/pip install --only-binary=:all: -r requirements-1146.txt
.venv/bin/python -B -m unittest -v test_regions.py
.venv/bin/python -B analyse.py --check

Repeat in a separate environment with requirements-1142.txt. Captures used h5py 3.10.0 / NumPy 1.26.4 / HDF5 1.14.2 and h5py 3.15.0 / NumPy 2.2.6 / HDF5 1.14.6; check the linked native version. Tests reopen retained images and regenerate cases in temporary files. Nine cases, two builds, two selections and before/after reads give 72 selection-read observations, not independent samples or an error-rate estimate.

Scope: native serial legacy region references, one-dimensional little-endian int32, v110 bounds, whole-chunk shrink boundaries and normal API changes, plus one raw-byte damage control. Modern opaque references, other VOL connectors, partial-chunk resizing, SWMR and crashes were not tested. This demonstrates documented behavior, not a newly discovered defect. Original code and fixtures are CC0-1.0; upstream sources retain their licenses.

What a restore test should establish

Folk and Pourmal distinguish format self-description, provenance and corruption detection in their 2010 preservation paper. Those are complementary archive requirements, not interchangeable guarantees. [Preservation paper, sections 2.3 and 3.1] Our controls make the distinction concrete: a readable, self-describing selection can still return a different data generation.

Inspect Dataset.is_virtual and virtual_sources() to discover VDS mappings; the latter exposes source names and selections. Those records describe dependencies, not their current availability or authenticity. [4]

  1. Inventory the intended data. Record source files, dataset paths, selections, shapes, types, units and the expected missing-data policy. Our two-file fixture is not a recursive dependency scanner.
  2. Capture a stable set. Preserve the required source versions together. Hashes taken during unrelated concurrent updates do not establish a consistent scientific snapshot.
  3. Control the reader environment. Restore in isolation from the originals and unintended search locations. Record or deliberately clear prefix settings and use a known working directory. Verify the identities of the sources actually selected.
  4. Check values and validity. Do not accept a correct shape or an error-free read as completeness. Apply the scientific schema and missing-value rules to the required array regions.

A materialized ordinary array is one option when self-contained delivery matters more than avoiding duplication. Our control copied the full array while both sources were present and checked against the fixture, then stayed unchanged through all source manipulations. Materializing after a missing-source read could instead preserve the fill values as ordinary data. The control copies this array only; it is not a general HDF5 export preserving every attribute, group or relationship.

This extends the distinction between backup verification and an actual restore. It differs from SWMR publication consistency: our writers were closed, yet file dependencies still changed what the reader obtained. The analogous archival question for compression is whether the required dictionary is preserved and identified.

VDS method, scope and reproduction

Each of eight scenarios starts from fresh private files and is repeated three times: 24 case runs, each reading two VDS arrays and one ordinary control. All handles close before files are changed. Every final observation runs in a fresh process with an empty working directory. Relocation removes the original fixture directory; prefix overrides are absent except in the named case. Full arrays, mapping records, hashes and process outcomes are retained.

Measured environment: Python 3.12.3, h5py 3.15.0, HDF5 1.14.6, NumPy 2.3.3; Linux, sec2 driver and explicit v110 format bounds. This is a controlled API demonstration on one host, not a failure-rate estimate. We did not test power loss, concurrent mutation, damaged sources, permission failures, network filesystems, unlimited selections, nested VDS or external links. A different source failure may raise an error.

The dataset page provides CSV, JSON, column definitions and provenance. Download the harness and pinned requirements into one directory:

python3 -m venv .venv
.venv/bin/pip install --only-binary=:all: -r hdf5-vds-requirements.txt
.venv/bin/python hdf5-vds.py --repetitions 3 > observations.json

The harness uses only private temporary files and bounded subprocess waits. Its runtime checks also execute under optimized Python. Original code and observations are CC0-1.0; upstream documentation and libraries retain their own licenses.

Primary sources

  1. h5py 3.15.0: Virtual Datasets
  2. The HDF Group: Introduction to the Virtual Dataset
  3. The HDF Group: H5Pset_virtual source-file resolution and H5Pset_fill_value
  4. h5py 3.15.0: Dataset.is_virtual and Dataset.virtual_sources
  5. Xing et al. (ICDE 2018): ArrayBridge: Interweaving declarative array processing in SciDB with imperative HDF5-based programs, sections V and VI
  6. The HDF Group: Dataset guide, External Storage Properties
  7. HDF5 1.14.6: H5D__efl_read EOF and open-error handling
  8. The HDF Group: H5Pset_efile_prefix and HDF5_EXTFILE_PREFIX
  9. h5py 3.15.0: Object and Region References, selection and nullness
  10. h5py 3.15.0: legacy H5Rcreate and H5Rget_region binding
  11. HDF5 1.14.6: legacy native region-reference encoding and lookup
  12. HDF5 1.14.6: H5Dset_extent shrink-loss and dataspace-handle contract
  13. Folk and Pourmal (US DPIF 2010): Balancing Performance and Preservation: Lessons learned with HDF5, sections 2.3 and 3.1

VDS documentation checked 17-18 October 2026; external-storage documentation checked 21 October 2026; region-reference contracts checked 12 November 2026. Measured library versions are stated separately.

Published by Hesela team · Published · Updated

Report a correction · Editorial standards · Reuse guidance

Change history

: first published.

: latest recorded update. A detailed change note is not available for this revision.

New-publication RSS · Correction RSS

Cite this page
Hesela team. HDF5 dependencies: missing sources and truncated raw data. Hesela. 2026-11-12. https://hesela.com/analyses/hdf5-virtual-datasets-missing-sources/