Executor callbacks are no longer in a predictable order
Maintainers usually reply within 1 day
@wjwwood is already working on this.
Since May 16, 2024.
Assessment
This issue has not been assessed yet.
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- Source
- Version or commit hash:
- DDS implementation:
- Fast-RTPS
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
- Build the https://github.com/boschresearch/ros2_response_time_analysis project against ROS2 Jazzy (note that some minimal changes are required).
- Observe that the results of running the test show that the callbacks are executed in an arbitrary order as compared to the previous ordering which was with respect to the order in which the subscriptions/services were added to the node.
Expected behavior
With ROS2 Eloquent through Iron, the callbacks all executed in the following order, where the ordering was defined by the order in which the subscriptions/services were added to the node.
Actual behavior
With ROS2 Jazzy, the ordering is now arbitrary and not related to the order in which messages were received or the order in which subscriptions were added to the node. The execution order of timers also appears to be affected.
NOTE: While the low, medium, and high subscriptions are processed in the same order that they are transmitted, I believe this to be a fluke as the service and timer callbacks are not processed in the order they were registered or sent. For reference, the callbacks are registered in the following order:
- high
- medium
- low
- srv_high
- srv_medium
- srv_low
- timers (as directed by the test)
And the topics/services are sent in the following order:
- low
- medium
- high
- srv_high
- srv_low
- low
- medium
- high
- srv_high
- srv_low
- srv_medium
- srv_medium
- high
With timers set to expire at 200, 200, 2300, and 2300 milliseconds into the test.
Additional information
I believe this change is a result of #2142 due to the EntityCollection class being based on std::unordered_map where the key is the handle returned by rcl for the timer/subscription/etc. The entities are then added to the wait set in whatever order they are iterated through by the std::unordered_map and thus processed in that order. I haven't had the opportunity to test it, but I believe the ordering could be different from system to system or even run to run as the rcl handle values change.
The default AllocatorMemoryStrategy used in previous versions of rclcpp utilized std:vector for storing rcl handles, which maintained the order in which they were added to the node.
- Dominant language
- C++
- Stars
- 829
- Forks
- 587
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 30
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/rclcpp
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Memory grows per callback group created and destroyed on long lived nodesPossibly taken @jwallace42 claimed this 1 day ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 28/100
ros2/rclcpp#3428 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
removing and immediately re-adding a node to the EventsCBGExecutor leaves its entities unregisteredPossibly taken @skyegalaxy claimed this 10 days ago. Openbug
ros2/rclcpp#3418 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Humble] Removing a node with more than one auto-added callback group leaves a dangling guard condition in the executorPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
ros2/rclcpp#3410 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
EchoTools/nevr-runtime#2912 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug-unconfirmed
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
libc++
Difficulty 1/5 Under an hour Newbie friendliness 88/100
llvm/llvm-project#246508 ·
Maintainers usually reply within 1 day