# Virtual dataset in read-write file missing data from read-only file

**URL:** <https://forum.hdfgroup.org/t/virtual-dataset-in-read-write-file-missing-data-from-read-only-file/5647>\
**Category:** HDF5 Library\
**Created:** [April 9, 2019, 2:25pm UTC](https://forum.hdfgroup.org/t/virtual-dataset-in-read-write-file-missing-data-from-read-only-file/5647 "2019-04-09T14:25:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas1](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/thomas1/32/1733_2.png) [@thomas1](https://forum.hdfgroup.org/u/thomas1)\
**Post date:** [April 9, 2019, 2:25pm UTC](https://forum.hdfgroup.org/t/virtual-dataset-in-read-write-file-missing-data-from-read-only-file/5647/1 "2019-04-09T14:25:52Z")

</div>

If I build a virtual dataset in a file with read/write access, but pointing to data in files with read-only access, I can only see the data by opening the new file in read-only mode. When I open it in read/write mode, the virtual dataset contains the fill value instead of the data.

Here’s a notebook replicating the issue via h5py: [https://gist.github.com/takluyver/577a0edf2fe67ea3590d8d5bced39c56](https://gist.github.com/takluyver/577a0edf2fe67ea3590d8d5bced39c56)

I’m guessing that HDF5 tries to open the source files with the same mode as the main file, and when that fails, it gives up on accessing the data. But in this case, opening the source files in read-only mode would work.

(This is exacerbated because h5py by default tries to open files for read/write access if possible. We’re aiming to change the default to read-only in the future.)

---

<div class="post-metadata">

**Author:** ![mrosanes](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mrosanes](https://forum.hdfgroup.org/u/mrosanes)\
**Post date:** [May 14, 2019, 2:42pm UTC](https://forum.hdfgroup.org/t/virtual-dataset-in-read-write-file-missing-data-from-read-only-file/5647/2 "2019-05-14T14:42:57Z")

</div>

I also reproduced this bug, in a conda environment.  
It would be nice if hdf5 was opening the source files in read-only mode in this case.

In any case, it would be interesting if hdf5 was reporting an error/warning if the source files could not be accessed. Filling the virtual dataset slices with the fillvalue if an error in the access of the source files is present (or if the source files are missing), should not be the behavior by default. A scientist could think that all data was recorded correctly, when in reality it could be missing data slices. Or maybe a flag for each source file could exist, indicating if the source file has been accessed correctly or not; allowing to check if the VDS has been correctly created with the data coming from the different source files.

---

<div class="post-metadata">

**Author:** ![thomas.vincent](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/t/6f9a4e/32.png) [@thomas.vincent](https://forum.hdfgroup.org/u/thomas.vincent)\
**Post date:** [October 2, 2025, 11:48am UTC](https://forum.hdfgroup.org/t/virtual-dataset-in-read-write-file-missing-data-from-read-only-file/5647/3 "2025-10-02T11:48:20Z")

</div>

Hi,

We’re also facing this issue when accessing read-only files from virtual dataset defined in a file opened in read-write mode.

Changing acc\_flags in the link access property list is taken into account for external link as expected but has no impact on Virtual Dataset (see [sample code](https://github.com/h5py/h5py/issues/2690#issuecomment-3319636132) to reproduce based on h5py).

Looking at the different [HDF5 property lists](https://support.hdfgroup.org/documentation/hdf5/latest/group___h5_p.html), I couldn’t find an equivalent of [H5Pset\_elink\_acc\_flags](https://support.hdfgroup.org/documentation/hdf5/latest/group___l_a_p_l.html#ga020f7eb2eae01043286af50db0a76d82) and [H5Pset\_elink\_fapl](https://support.hdfgroup.org/documentation/hdf5/latest/group___l_a_p_l.html#ga3895e8e60ce8f0b6f32ab7a22c715d1a) for virtual dataset.

Since there is already a [H5Pset\_virtual\_prefix](https://support.hdfgroup.org/documentation/hdf5/latest/group___d_a_p_l.html#ga6816e0de35a335f636922c3cd5569819) for Dataset access property list, wouldn’t that make sense to also have set\_virtual\_acc\_flags and set\_virtual\_fapl?

Best,

---

<div class="post-metadata">

**Author:** ![jhenderson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@jhenderson](https://forum.hdfgroup.org/u/jhenderson)\
**Post date:** [October 2, 2025, 3:39pm UTC](https://forum.hdfgroup.org/t/virtual-dataset-in-read-write-file-missing-data-from-read-only-file/5647/4 "2025-10-02T15:39:25Z")

</div>

Hi @thomas.vincent,

you may be interested in tracking [Virtual datasets: control how errors are handled when opening source files · Issue #5088 · HDFGroup/hdf5 · GitHub](https://github.com/HDFGroup/hdf5/issues/5088), previously reported by @thomas1. We’re at least aware of the issues, though no progress toward a solution has been made yet.
