ros2 / rmw_cyclonedds

ROS 2 RMW layer for Eclipse Cyclone DDS
Apache License 2.0
107 stars 89 forks source link

Composable node randomly not loading when shared memory is used. #472

Open ksuszka opened 9 months ago

ksuszka commented 9 months ago

Bug report

Required Info:

Steps to reproduce issue

I prepared separate repo with very simple application and launch file to reproduce the issue https://github.com/ksuszka/cyclonedds_iceoryx_components_issue_demo.

Using this repo:

Build docker image:

docker build -f Dockerfile -t cyclone-component-test .

Open three terminal windows.

In the first terminal window start a docker container with the iox-roudi memory server:

docker run -it --shm-size 1GB --rm --name cyclone-component-test cyclone-component-test iox-roudi
Showing correct behavior with SHM disabled

First, run an example without shared memory to see the correct result.

In the second terminal window run the launch file which spawns 90 component_containers and loads a composable node into each:

docker exec -it --env=CYCLONEDDS_URI='<Domain id="any"><SharedMemory><Enable>false</></></>' cyclone-component-test bash -c ". /ws/install/setup.bash && ros2 launch /ws/src/composition.launch.py"

In the third terminal check how many component_containers were created:

docker exec -it cyclone-component-test bash -c "pgrep -f -c component_container"

You should get the number 90.

And now check how many nodes were created:

docker exec -it cyclone-component-test bash -c ". /ws/install/setup.bash && ros2 node list -c"

You should get the number 181 = 1 launch file + 90 containers + 90 composable nodes.

Showing incorrect behavior with SHM enabled

Now abort an execution in the second terminal by Ctrl+C and run the same command enabling shared memory support:

docker exec -it --env=CYCLONEDDS_URI='<Domain id="any"><SharedMemory><Enable>true</></></>' cyclone-component-test bash -c ". /ws/install/setup.bash && ros2 launch /ws/src/composition.launch.py"

In the third terminal check how many component_containers were created:

docker exec -it cyclone-component-test bash -c "pgrep -f -c component_container"

You should again get the number 90.

And now check how many nodes were created:

docker exec -it cyclone-component-test bash -c ". /ws/install/setup.bash && ros2 node list -c"

You will probably get a number lower than 181 - not all composable nodes were loaded.

Expected behavior

Composable nodes are loaded regardless if SHM is enabled/disabled

Actual behavior

Composable nodes sometimes don't load if SHM is enabled.

Additional information

The issue was observed in ROS system with a few dozens of nodes. Starting the system with SHM enabled caused random nodes to not being loaded.

The code repository contains a minimal example which demonstrates the issue using the standard Iceoryx compilation. As far as I tested, the type of composable node loaded doesn't matter, however in that repository the composable node with the /parameter_events publisher disabled is used so a large number of nodes can be spawned without triggering the https://github.com/eclipse-cyclonedds/cyclonedds/issues/1326#issuecomment-1181699596 issue.