Skip to content

[FIX] FIAMSScheduler_test: fix OMP race by using distinct time windows per CSV row - #9638

Merged
timosachsenberg merged 2 commits into
developfrom
claude/laughing-wozniak-r70yi7
Jun 20, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
claude/laughing-wozniak-r70yi7

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

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 for and 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 same filename and the same time=10, so they wrote to identical output paths concurrently.

Race sequence:

Thread A (row 0, load_cached_=true): File::exists(SerumTest_picked_10.mzML) → false
                                      → enters "calculate" path → creates/opens file
Thread B (row 1, load_cached_=true): File::exists(SerumTest_picked_10.mzML) → TRUE (empty/partial)
                                      → enters "load cached" path → XML parse on empty file
                                      → uncaught exception in OMP thread → SIGABRT

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=20 instead of time=10. The two OMP threads now write to SerumTest_10.* and SerumTest_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 parsed
  • TEST_EQUAL(samples[1].at("time"), "20") — second row is distinct
  • TEST_EQUAL(File::exists(.../SerumTest_20.mzTab), true) — second OMP thread produced output

Test plan

  • Confirm FIAMSScheduler_test passes on macOS ARM64 (macos-15, xcode 16.4) nightly
  • Confirm the new TEST_EQUAL(samples[1].at("time"), "20") and existence check pass

🤖 Generated with Claude Code

https://claude.ai/code/session_01H6ajxzVLb7eqJbvV2XmsAy

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for multi-sample processing, verifying correct handling of multiple samples and their corresponding output files.

…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
@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Claude

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
@timosachsenberg timosachsenberg changed the title [FIX] FIAMSScheduler_test: remove duplicate CSV row that causes OMP race condition [FIX] FIAMSScheduler_test: fix OMP race by using distinct time windows per CSV row Jun 20, 2026
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The FIAMSScheduler test is extended with four additional assertions: samples.size() equals 2, the second sample's "time" is "20", and after run(), SerumTest_20.mzTab exists in the temporary output directory alongside the pre-existing equality check for SerumTest_10.mzTab.

Changes

FIAMSScheduler test – second sample coverage

Layer / File(s) Summary
Expanded sample and output file assertions
src/tests/class_tests/openms/source/FIAMSScheduler_test.cpp
Checks samples.size() == 2, asserts the second sample's "time" is "20", and verifies SerumTest_20.mzTab exists in the output directory after fia_scheduler.run().

🐇 Two samples now, not just one,
The scheduler's second job is done!
SerumTest_20 takes its place,
Asserted with asserting grace.
The rabbit checks them, hop by hop — ✅

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing an OMP race condition in the FIAMSScheduler_test by using distinct time windows per CSV row, which matches the core objective of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/laughing-wozniak-r70yi7

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c81e05 and 04949c5.

⛔ Files ignored due to path filters (1)
  • src/tests/class_tests/openms/data/FIAMS_input/params_test.csv is excluded by !**/*.csv
📒 Files selected for processing (1)
  • src/tests/class_tests/openms/source/FIAMSScheduler_test.cpp

Comment on lines 59 to +64
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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

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.

2 participants