Repository navigation
[FIX] FIAMSScheduler_test: fix OMP race by using distinct time windows per CSV row - #9638
Conversation
…condition The test CSV had two identical rows for the same sample (SerumTest, time=10). FIAMSScheduler::run() uses #pragma omp parallel for, so both rows were processed concurrently. Since FIAMSScheduler defaults load_cached_=true, both threads call FIAMSDataProcessor::run() with load_cached_spectrum=true. Thread A writes SerumTest_picked_10.mzML; before it finishes, Thread B sees the (empty/partial) file via File::exists() and tries to load it as a cached spectrum, hitting an XML parse error that propagates as an uncaught exception in the OMP thread → SIGABRT → FIAMSScheduler_test reports "Subprocess aborted". The duplicate row has no purpose: the test only asserts on samples[0] and checks a single output mzTab. Removing it leaves one sample to process, eliminating the race entirely. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Claude-Session: https://claude.ai/code/session_01H6ajxzVLb7eqJbvV2XmsAy
|
@timosachsenberg The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-06-20 03:41:29.270706501 +0000
+++ AUTHORS.new 2026-06-20 03:41:34.248796721 +0000
@@ -25,6 +25,7 @@
- Chris Bielow
- Christian Ehrlich
- Christie Mathews
+ - Claude
- Clemens Groepl
- Cornelia Friedle
- Daniel Jameson |
…s per row
The original intent (confirmed via git history) was to test OMP-parallel
processing of multiple samples: the #pragma omp parallel for and the two
CSV rows were added in the same commit. The bug was that both rows shared
the same filename AND time window, so they wrote to identical output paths
concurrently — a race between Thread A writing SerumTest_picked_10.mzML
and Thread B trying to load it as a cached spectrum (load_cached_=true
is the FIAMSScheduler default).
Fix: give the second row time=20 instead of time=10. The two threads now
write to SerumTest_{10,20}.mzTab (and their intermediate mzML files),
eliminating the path collision. OMP parallelism is preserved and exercised.
Also tighten the test assertions:
- TEST_EQUAL(samples.size(), 2) — both rows were parsed
- TEST_EQUAL(samples[1].at("time"), "20") — second row is distinct
- TEST_EQUAL(File::exists(.../SerumTest_20.mzTab), true) — second OMP
thread actually completed and produced output
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H6ajxzVLb7eqJbvV2XmsAy
📝 WalkthroughWalkthroughThe ChangesFIAMSScheduler test – second sample coverage
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tests/class_tests/openms/source/FIAMSScheduler_test.cpp`:
- Around line 59-64: The File::exists assertion on line 64 does not verify that
fia_scheduler.run() actually produced the SerumTest_20.mzTab file in this test
invocation; it only checks if the file exists, which could be a stale artifact
from a previous run. To harden this test against stale artifacts, ensure the
temporary output directory is clean before running fia_scheduler.run() by either
explicitly removing the FIAMS_output directory before the test execution or
using the NEW_TMP_FILE pattern to create isolated temporary outputs as required
by the testing guidelines. This ensures the File::exists check on the second
output file strictly proves that the current test run produced it.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fc10d0e2-6a01-4c10-b5ce-0a95f933dac1
⛔ Files ignored due to path filters (1)
src/tests/class_tests/openms/data/FIAMS_input/params_test.csvis excluded by!**/*.csv
📒 Files selected for processing (1)
src/tests/class_tests/openms/source/FIAMSScheduler_test.cpp
| fia_scheduler.run(); | ||
| std::string outfile =StringUtils::toStr(OPENMS_GET_TEST_DATA_PATH("FIAMS_output/SerumTest_10.mzTab")); | ||
| std::string outfile2 = tmp_dir + "FIAMS_output/SerumTest_10.mzTab"; | ||
| TEST_FILE_EQUAL(outfile2.c_str(), outfile.c_str()); | ||
| // verify the second OMP-parallel row also produced output | ||
| TEST_EQUAL(File::exists(tmp_dir + "FIAMS_output/SerumTest_20.mzTab"), true); |
There was a problem hiding this comment.
Harden the new second-output assertion against stale artifacts
Line 64 can pass even if SerumTest_20.mzTab already exists from a previous run, so this assertion does not strictly prove fia_scheduler.run() produced it in this test invocation.
As per coding guidelines, tests under src/tests/**/*_test.cpp should use isolated temp outputs (NEW_TMP_FILE) to avoid cross-test artifacts.
Suggested change
- fia_scheduler.run();
+ const std::string second_out = tmp_dir + "FIAMS_output/SerumTest_20.mzTab";
+ TEST_EQUAL(File::exists(second_out), false);
+ fia_scheduler.run();
std::string outfile =StringUtils::toStr(OPENMS_GET_TEST_DATA_PATH("FIAMS_output/SerumTest_10.mzTab"));
std::string outfile2 = tmp_dir + "FIAMS_output/SerumTest_10.mzTab";
TEST_FILE_EQUAL(outfile2.c_str(), outfile.c_str());
// verify the second OMP-parallel row also produced output
- TEST_EQUAL(File::exists(tmp_dir + "FIAMS_output/SerumTest_20.mzTab"), true);
+ TEST_EQUAL(File::exists(second_out), true);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/tests/class_tests/openms/source/FIAMSScheduler_test.cpp` around lines 59
- 64, The File::exists assertion on line 64 does not verify that
fia_scheduler.run() actually produced the SerumTest_20.mzTab file in this test
invocation; it only checks if the file exists, which could be a stale artifact
from a previous run. To harden this test against stale artifacts, ensure the
temporary output directory is clean before running fia_scheduler.run() by either
explicitly removing the FIAMS_output directory before the test execution or
using the NEW_TMP_FILE pattern to create isolated temporary outputs as required
by the testing guidelines. This ensures the File::exists check on the second
output file strictly proves that the current test run produced it.
Source: Coding guidelines
Summary
The nightly CI failed on macOS ARM64 (macos-15, xcode 16.4) with
FIAMSScheduler_test (Subprocess aborted).Root cause (confirmed via git history): The
#pragma omp parallel forand the two duplicate CSV rows were added in the same commit (Feb 2020, sgalkina). The intent was to test OMP-parallel processing of multiple samples — but both rows had the samefilenameand the sametime=10, so they wrote to identical output paths concurrently.Race sequence:
This race was latent since 2020 but only now surfaces on macOS ARM64 where OMP scheduling is fast enough to expose the sub-millisecond window.
Fix
Give the second row
time=20instead oftime=10. The two OMP threads now write toSerumTest_10.*andSerumTest_20.*respectively — no path collision, OMP parallelism is preserved.Also tighten test assertions to explicitly verify both rows ran:
TEST_EQUAL(samples.size(), 2)— both rows parsedTEST_EQUAL(samples[1].at("time"), "20")— second row is distinctTEST_EQUAL(File::exists(.../SerumTest_20.mzTab), true)— second OMP thread produced outputTest plan
FIAMSScheduler_testpasses on macOS ARM64 (macos-15, xcode 16.4) nightlyTEST_EQUAL(samples[1].at("time"), "20")and existence check pass🤖 Generated with Claude Code
https://claude.ai/code/session_01H6ajxzVLb7eqJbvV2XmsAy
Summary by CodeRabbit