Skip to content

Fix UniqueIdGenerator seed collision in parallel pipelines - #8678

Merged
timosachsenberg merged 2 commits into
developfrom
fix/uniqueid-seed-collision
Jan 18, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
fix/uniqueid-seed-collision

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jan 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix seed collision in UniqueIdGenerator when multiple TOPP tools start simultaneously
  • Add SysInfo::getProcessId() as cross-platform wrapper for process ID retrieval

Problem

When multiple TOPP tools run in parallel (e.g., in TOPPAS pipelines), they can initialize at the same microsecond, resulting in identical RNG seeds. This causes duplicate UniqueIds across different files, leading to errors like:

FeatureHandle exists twice in ConsensusMap!

Solution

Mix the process ID into the seed using XOR with a 32-bit shift:

seed_ ^= static_cast<UInt64>(SysInfo::getProcessId()) << 32;

This ensures parallel processes get different seeds even when started at the exact same microsecond.

Test plan

  • Existing tests pass
  • QualityControl.toppas pipeline test no longer fails intermittently on Windows

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added process ID retrieval to system information utilities, exposing a public method to obtain the current process ID.
    • Enhanced unique identifier generation to mix in the process ID, reducing the risk of ID collisions for concurrently started instances.
    • Implemented cross-platform support for the new process ID capability so it works on supported OSes.

✏️ Tip: You can customize this high-level summary in your review settings.

Mix process ID into the seed to ensure different seeds for parallel
processes started at the same microsecond. This prevents duplicate
UniqueIds when multiple TOPP tools run simultaneously in a pipeline,
which was causing "FeatureHandle exists twice in ConsensusMap" errors
in QualityControl.

The seed now combines:
- Microsecond-resolution time (existing)
- Process ID shifted to upper 32 bits (new)

Added SysInfo::getProcessId() as a cross-platform wrapper for getpid().

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jan 18, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added SysInfo::getProcessId() with platform-specific implementations and used it in UniqueIdGenerator::init_() to mix the process ID into the RNG seed via a left-shifted XOR.

Changes

Cohort / File(s) Summary
SysInfo Interface & Implementation
src/openms/include/OpenMS/SYSTEM/SysInfo.h, src/openms/source/SYSTEM/SysInfo.cpp
Declared and implemented static Int64 getProcessId(); uses _getpid() on Windows and getpid() on POSIX; added required platform headers.
UniqueIdGenerator Integration
src/openms/source/CONCEPT/UniqueIdGenerator.cpp
Included OpenMS/SYSTEM/SysInfo.h and XORed (process_id << 32) into the existing seed_ in init_() to vary seeds across processes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibble bits and seed the night,
A PID hop left, then XORed right,
Tiny shifts, a randomness tune,
Unique IDs beneath the moon ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: fixing UniqueIdGenerator seed collision in parallel pipelines, which is the primary objective addressed by mixing the process ID into the RNG seed.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@claude

claude Bot commented Jan 18, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@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

🤖 Fix all issues with AI agents
In `@src/openms/include/OpenMS/SYSTEM/SysInfo.h`:
- Around line 45-48: The Doxygen comment for the new API does not use the
required `@brief` style; update the comment for SysInfo::getProcessId() to use the
`@brief` tag and a one-line summary followed by any additional tags (e.g.,
`@return`) as needed so it conforms to the project Doxygen guidelines; locate the
declaration of static Int64 getProcessId() in class SysInfo and replace the
current comment block with a `@brief` line plus the existing `@return` description.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@timosachsenberg
timosachsenberg merged commit fe9a857 into develop Jan 18, 2026
@timosachsenberg
timosachsenberg deleted the fix/uniqueid-seed-collision branch January 18, 2026 11:27
claude Bot pushed a commit that referenced this pull request Jan 18, 2026
Added 19 missing PRs to OpenMS 3.6.0 changelog:

PyOpenMS:
- #8530: Build system modernization with py-build-cmake
- #8633: SpectrumNativeIDParser wrapper
- #8655: Arrow/Parquet export with DataFrame methods (BREAKING: method renames)
- #8661: Build dependency docs
- #8664: Biosaur2Algorithm wrap-inherits
- #8668: wrap-doc documentation
- #8674: Docstring validation tests

TOPP tools:
- #8643: FileInfo FASTA stats
- #8650: FileConverter MSP support
- #8649: PeakPickerHiRes parameter

OpenMS Library:
- #8633: SpectrumNativeIDParser class
- #8655: ArrowExport helper
- #8651, #8656, #8659, #8660, #8662: Performance optimizations

Fixes:
- #8645: DataArray handling in filters
- #8672: Test file correction
- #8678: UniqueIdGenerator seed collision fix

Build System:
- #8675, #8676: Claude CI workflows

Also reorganized misplaced entries from lines 122-129.

Co-authored-by: Timo Sachsenberg <[email protected]>
timosachsenberg added a commit that referenced this pull request Jan 18, 2026
* Add comprehensive changelog for OpenMS 3.6.0

Includes changes from 96 merged PRs since version 3.5.0:

- General: macOS Intel discontinued, Ubuntu 24.04, notarization in CI
- Dependencies: Autowrap >= 0.26.0, Eigen minimum 3.4.0
- PyOpenMS: Pythonic methods (__len__, __str__, __repr__, __hash__),
  DataFrame support, new wrappers, string handling improvements
- TOPP tools: MapAligner spectra transformation, FileInfo improvements,
  IsobaricWorkflow fixes, SageAdapter thread handling
- OpenMS Library: PeakFileOptions, ParamIterator, SpectrumAnnotator
- Breaking changes: Matrix<T> Eigen decoupling, API renames, FileWatcher move
- Bug fixes: NucleicAcidSearchEngine, LogConfigHandler, decoy generation
- Documentation: Targeted Quantitation, parameter annotations, AGENTS.md
- Build: macOS notarization, Parquet support, pytest fixtures

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Add missing changelog entries for recently merged PRs

Added 19 missing PRs to OpenMS 3.6.0 changelog:

PyOpenMS:
- #8530: Build system modernization with py-build-cmake
- #8633: SpectrumNativeIDParser wrapper
- #8655: Arrow/Parquet export with DataFrame methods (BREAKING: method renames)
- #8661: Build dependency docs
- #8664: Biosaur2Algorithm wrap-inherits
- #8668: wrap-doc documentation
- #8674: Docstring validation tests

TOPP tools:
- #8643: FileInfo FASTA stats
- #8650: FileConverter MSP support
- #8649: PeakPickerHiRes parameter

OpenMS Library:
- #8633: SpectrumNativeIDParser class
- #8655: ArrowExport helper
- #8651, #8656, #8659, #8660, #8662: Performance optimizations

Fixes:
- #8645: DataArray handling in filters
- #8672: Test file correction
- #8678: UniqueIdGenerator seed collision fix

Build System:
- #8675, #8676: Claude CI workflows

Also reorganized misplaced entries from lines 122-129.

Co-authored-by: Timo Sachsenberg <[email protected]>

---------

Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Timo Sachsenberg <[email protected]>
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