Skip to content

Fix race condition when creating isolated component container - #3223

Merged
skyegalaxy merged 2 commits into
ros2:rollingfrom
botsandus:race-condition-load-composable
Aug 13, 2026
Merged

Fix race condition when creating isolated component container#3223
skyegalaxy merged 2 commits into
ros2:rollingfrom
botsandus:race-condition-load-composable

Conversation

@tonynajjar

Copy link
Copy Markdown
Contributor

Description

Fix race condition when creating isolated component container

What

The isolated component_container created a throwaway ComponentManager solely to read the thread_num parameter, then destroyed it and re-created the real ComponentManagerIsolated. This briefly advertised the container's ~/_container/load_node service and tore it down, racing LoadComposableNodes clients and silently dropping load requests.

Changes

  • component_container.cpp: construct the manager once, directly as its final type. Isolated managers are now built with num_threads == 0 ("auto").
  • component_manager_isolated.hpp: in add_node_to_executor, num_threads_ == 0 now resolves the thread_num parameter itself (defaults to hardware concurrency), so the container no longer needs to read it up front.
  • Added a regression test (isolated_multi_threaded_auto_thread_num) covering the isolated multi-threaded "auto" path.

Notes

  • ABI-safe: only an executable and an inline template method body change; ComponentManager's layout is untouched.
  • Behavior preserved, including -p thread_num:=N for isolated multi-threaded/events executors.
  • Cleanly backportable to lyrical (identical baseline).

Fixes #3222

Is this user-facing behavior change?

Did you use Generative AI?

Additional Information

…ad_num parameter dynamically

Signed-off-by: Tony Najjar <tony.najjar@dexory.com>
…ad resolution

Signed-off-by: Tony Najjar <tony.najjar@dexory.com>
@tonynajjar tonynajjar changed the title Refactor thread management in ComponentManagerIsolated to handle thread_num parameter dynamically Fix race condition when creating isolated component container Aug 12, 2026
@tonynajjar

Copy link
Copy Markdown
Contributor Author

@skyegalaxy 🙏

@mergify

mergify Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skyegalaxy
skyegalaxy self-requested a review August 12, 2026 15:49
@skyegalaxy

Copy link
Copy Markdown
Member

Pulls: #3223, ros2/launch_ros#563
Gist: https://gist.githubusercontent.com/skyegalaxy/5232fda883b941f580d1e2a05fb88104/raw/06dc7d1a96039fe48d3fc8d422cbe562820d1792/ros2.repos
BUILD args:
TEST args:
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20066

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@skyegalaxy
skyegalaxy merged commit 81ec3e3 into ros2:rolling Aug 13, 2026
3 checks passed
@skyegalaxy

Copy link
Copy Markdown
Member

https://github.com/Mergifyio backport lyrical

@mergify

mergify Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

backport lyrical

✅ Backports have been created

Details

skyegalaxy pushed a commit that referenced this pull request Aug 13, 2026
…#3228)

* Refactor thread management in ComponentManagerIsolated to handle thread_num parameter dynamically



* Add test for isolated multi-threaded component manager with auto thread resolution



---------


(cherry picked from commit 81ec3e3)

Signed-off-by: Tony Najjar <tony.najjar@dexory.com>
Co-authored-by: Tony Najjar <tony.najjar@dexory.com>

@fujitatomoya fujitatomoya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm with green CI.

@fujitatomoya

Copy link
Copy Markdown
Collaborator

ah, sorry one step behind. the comment was cached in the browser.

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.

Race condition when loading multiple isolated component_container

3 participants