Skip to content

tests/hdf5: flush H5File before objectExists on unlink tests - #41

Merged
transfix merged 1 commit into
masterfrom
ci/fix-hdf5-unlink-flush
May 5, 2026
Merged

transfix merged 1 commit into
masterfrom
ci/fix-hdf5-unlink-flush

Conversation

@transfix

@transfix transfix commented May 5, 2026

Copy link
Copy Markdown
Owner

Fixes a non-deterministic CI failure of HDF5Test.UnlinkNestedObject on macOS Release that caused the master pipeline for #38 to go red.

Value of: hdf5_utils::objectExists(ctx, filepath, "group/subgroup/data")
  Actual: false
Expected: true

objectExists() opens a separate H5File handle internally; on macOS Release the H5 library is free to keep the freshly-created dataset's metadata buffered against the original write handle past the inner Group/DataSet release point, so the secondary read handle sees a file without the new object.

Force a global flush after each create/unlink before calling objectExists(). Same fix applied to the sibling HDF5Test.UnlinkDataSet for symmetry — it shares the exact same race pattern.

Verified locally: 2/2 pass after the fix.

The macOS Release CI builder of the master pipeline for #38 failed
HDF5Test.UnlinkNestedObject:

  Value of: hdf5_utils::objectExists(ctx, filepath, "group/subgroup/data")
    Actual: false
  Expected: true

The test creates a nested group/subgroup/data dataset, then calls
objectExists() (which opens a *separate* H5File handle internally to
do its check). On macOS Release the H5 library is free to keep the
new dataset's metadata buffered against the original handle past the
inner Group/DataSet release point, so the secondary handle observes
a file in which the dataset does not yet exist and the assertion
fails non-deterministically.

Force a global flush after each create/unlink before calling
objectExists(). Apply the same fix to the sibling
HDF5Test.UnlinkDataSet for symmetry, since it has the exact same
pattern and would race the same way under load.
@transfix
transfix merged commit eca9f03 into master May 5, 2026
19 checks passed
@transfix
transfix deleted the ci/fix-hdf5-unlink-flush branch May 5, 2026 01:09
transfix added a commit that referenced this pull request May 5, 2026
The HDF5Test fixture's temp dir was '/<binary_dir>/hdf5_test_<thread_id>'.
Each ctest case is a separate process invocation but std::this_thread::get_id()
for the main thread is frequently reused across freshly-spawned processes
on macOS, so parallel ctest workers were colliding on the same on-disk
directory and stomping each other's H5 files. That surfaced as flaky
'unknown file: Failure' / 'objectExists() == false' failures on
test/macos-latest/Release for PR #42 even though the master baseline
already includes the H5F_SCOPE_GLOBAL flush fix from #41.

Make the directory name include the process id, an atomic per-process
counter, and a steady_clock timestamp in addition to the thread id, so
no two test instances (within or across processes) can collide.

Wrap getpid() in a portable shim (process.h::_getpid on Windows,
unistd.h::getpid elsewhere).
transfix added a commit that referenced this pull request May 5, 2026
The HDF5Test fixture's temp dir was '/<binary_dir>/hdf5_test_<thread_id>'.
Each ctest case is a separate process invocation but std::this_thread::get_id()
for the main thread is frequently reused across freshly-spawned processes
on macOS, so parallel ctest workers were colliding on the same on-disk
directory and stomping each other's H5 files. That surfaced as flaky
'unknown file: Failure' / 'objectExists() == false' failures on
test/macos-latest/Release for PR #42 even though the master baseline
already includes the H5F_SCOPE_GLOBAL flush fix from #41.

Make the directory name include the process id, an atomic per-process
counter, and a steady_clock timestamp in addition to the thread id, so
no two test instances (within or across processes) can collide.

Wrap getpid() in a portable shim (process.h::_getpid on Windows,
unistd.h::getpid elsewhere).
transfix added a commit that referenced this pull request May 5, 2026
* test(state): replace file-scope test_ctx with per-test fixture

Convert all 126 TEST() macros in state_test.cpp to TEST_F(StateTestFixture,
...). Each test now gets a fresh cvc::app, isolating per-test state roots
instead of sharing the file-scope 'static cvc::app test_ctx;' crutch.

- Add StateTestFixture with a per-test cvc::app ctx member.
- Convert lambda bodies that reference ctx to capture 'this'.
- Give the GuardedCallback helper struct an explicit cvc::app& reference
  so its operator() can reach the fixture's ctx.

All 126 StateTestFixture cases pass locally (1 perf case skipped).

* tests/hdf5: make per-test temp dir unique across parallel processes

The HDF5Test fixture's temp dir was '/<binary_dir>/hdf5_test_<thread_id>'.
Each ctest case is a separate process invocation but std::this_thread::get_id()
for the main thread is frequently reused across freshly-spawned processes
on macOS, so parallel ctest workers were colliding on the same on-disk
directory and stomping each other's H5 files. That surfaced as flaky
'unknown file: Failure' / 'objectExists() == false' failures on
test/macos-latest/Release for PR #42 even though the master baseline
already includes the H5F_SCOPE_GLOBAL flush fix from #41.

Make the directory name include the process id, an atomic per-process
counter, and a steady_clock timestamp in addition to the thread id, so
no two test instances (within or across processes) can collide.

Wrap getpid() in a portable shim (process.h::_getpid on Windows,
unistd.h::getpid elsewhere).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant