Fix bug in timers lifecycle for events executor#2586
Conversation
|
@alsora @mauropasse FYI |
rclcpp/src/rclcpp/experimental/executors/events_executor/events_executor.cpp
Outdated
Show resolved
Hide resolved
|
The test is a good step, unfortunately, in its current form, it does not guarantee that it will catch regressions. To guarantee that we should maybe use a custom allocator with placement new, but I'm not sure how easy/hard is to do that. |
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
4b962ef to
52eb7e9
Compare
Thanks for the review, Alberto. I have just pushed an update addressing all the other comments but this one is still pending. I might need some assistance with the custom allocator with placement new in case it's required. |
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
52eb7e9 to
9dcceee
Compare
rclcpp/src/rclcpp/experimental/executors/events_executor/events_executor.cpp
Show resolved
Hide resolved
|
@apojomovsky I think that the PR is good to go. |
Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
Thanks Alberto, I just pushed some changes addressing the findings. It should be good to go now. |
|
Retriggered CI due to what appears to be an unrelated failure in Windows: (thanks, @Crola1702 ) |
* Remove expired timers before updating the collection Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add regression test for reinitialized timers bug Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add missing includes Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Relocate test under the executors directory Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Extend test to run with all supported executors Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Adjust comment in fix to make it more generic Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Apply ament clang format to test Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Fix uncrustify findings Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> --------- Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
* Remove expired timers before updating the collection Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add regression test for reinitialized timers bug Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add missing includes Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Relocate test under the executors directory Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Extend test to run with all supported executors Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Adjust comment in fix to make it more generic Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Apply ament clang format to test Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Fix uncrustify findings Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> --------- Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit 9ef9646)
* Remove expired timers before updating the collection Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add regression test for reinitialized timers bug Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add missing includes Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Relocate test under the executors directory Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Extend test to run with all supported executors Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Adjust comment in fix to make it more generic Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Apply ament clang format to test Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Fix uncrustify findings Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> --------- Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit 9ef9646)
* Remove expired timers before updating the collection Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add regression test for reinitialized timers bug Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add missing includes Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Relocate test under the executors directory Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Extend test to run with all supported executors Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Adjust comment in fix to make it more generic Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Apply ament clang format to test Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Fix uncrustify findings Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> --------- Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit 9ef9646)
* Remove expired timers before updating the collection Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add regression test for reinitialized timers bug Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add missing includes Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Relocate test under the executors directory Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Extend test to run with all supported executors Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Adjust comment in fix to make it more generic Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Apply ament clang format to test Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Fix uncrustify findings Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> --------- Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit 9ef9646)
* Add logs on failed take response/request (#107) * Ignore local endpoints (#131) * Refs #18846: PoC ignore local endpoints: extend RCLCPP API Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> * Refs #18846: PoC ignore local endpoints: modify RCLCPP publish logic Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> --------- Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Co-authored-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> (cherry picked from commit 106c03a) style * Support intra-process communication: Clients & Services (ros2#1847) Signed-off-by: Mauro Passerino <mpasserino@irobot.com> (cherry picked from commit 58d2a04) Remove redundant `add_subscription` cherry pick artifact use const ref instead of ptr, add missing capacity fn more style * Jazzy recreation of "Add action client/server IPC support" (aeacde9) * add override attribute to some ipc methods Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> * clear intra-process manager on client/server destructors (#94) (cherry picked from commit 378223d) * move ipc lock to appropriate position in client.hpp (cherry picked from commit 9de603e) * Actions: Use ipc_setting = rclcpp::IntraProcessSetting::NodeDefault (#133) Co-authored-by: Mauro Passerino <mpasserino@irobot.com> * Allow for deferred responses with ipc (#135) * allow for deferred responses with ipc * fix send response * fix use member service ipc process * add map to store CallbackInfoVariant * add send_response to base class, set function ptr to get handle * move service intra process outside base * copy response into shared pointer for ipc * add typename for service template * remove ref signature * try without std::ref * try without ref wrapper * try emplace * make pair with variant * some cleanup * erase callback info if client invalid * add post_init_setup for services * fix extra comma * add post init setup after lifecycle node services * add documentation for ServiceIntraProcess template change * use weak ptr to service in ServiceIntraProcess * move check for valid service handle to beginning of function * add comment for callback info map (cherry picked from commit aa95a48) * check request header for intraprocess (#139) * check request header for intraprocess * set request header intraprocess to false in execute_service (cherry picked from commit a617f93) * Include namespaces in service names (#140) * Include node namespace in IPC Action service name * Include node namespace in IPC Client/Service service name --------- Co-authored-by: Mauro Passerino <mpasserino@irobot.com> (cherry picked from commit f5b2001) remove whitespace in service.hpp * Fix mutltiple client requests (#142) * store map of unique request id to client id and callback info pair * fix map end check * fix undefined reference * remove unnecessary request id erase, remove/fix unique id comment * improve unique id comment (cherry picked from commit b865383) * RECREATION OF Fixes for intra-process actions (#144) action client / server ipc decrustification whitespace / line length / uncrustify - service_intra_process const correctness * add logs and minor fixes (#146) * add logs and minor fixes Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> * use >0 rather than ==1 in comparison Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> --------- Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> * correct template syntax Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> (cherry picked from commit d4dd4e4) * avoid adding notify waitable twice to events-executor collection (ros2#2564) * avoid adding notify waitable twice to events-executor entities collection Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> * remove redundant mutex lock Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> --------- Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> (cherry picked from commit f27bdbf) * Fix bug in timers lifecycle for events executor (ros2#2586) * Remove expired timers before updating the collection Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add regression test for reinitialized timers bug Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Add missing includes Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Relocate test under the executors directory Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Extend test to run with all supported executors Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Adjust comment in fix to make it more generic Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Apply ament clang format to test Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> * Fix uncrustify findings Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> --------- Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit 9ef9646) * Bring lock_free_events_queue to rclcpp from the events_executor repo (#149) Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit 30050c1) exclude lock free queue from linting actually lint lock_free_events_queue lock_free_events_queue copyright whitespace / line length / uncrustify - lock_free_events_queue * Add test_actions (#150) Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> (cherry picked from commit aef928d) * Jazzy - Action IPC Fixes (See 7a51f00) whitespace / line length / uncrustify - rclcpp_action client whitespace / line length / uncrustify - rclcpp_action server fix duplicate member definitions in rclcpp_action server.hpp fixes for IPC action server delete log whitespace / line length / uncrustify - rclcpp action server again minor action client fixes whitespace / line length / uncrustify - rclcpp action client again * Always publish inter-process on TRANSIENT_LOCAL pubs (#152) * Mauro/irobot iron fixes (#155) whitespace / line length / uncrustify - publisher proper inter_process_publish_needed whitespace / line length / uncrustify - rclcpp publisher * Add test_actions & test_transient_local (#157) Co-authored-by: Mauro Passerino <mpasserino@irobot.com> (cherry picked from commit cf182e0) whitespace / line length / uncrustify - test_actions and test_transient_local whitespace / line length / uncrustify - test actions and transient_local again remove redundant test_actions * Call service post_init_setup in test_service.cpp --------- Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com> Signed-off-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com> Co-authored-by: Mauro Passerino <mpasserino@irobot.com> Co-authored-by: mauropasse <mauropasse@hotmail.com> Co-authored-by: Alberto Soragna <alberto.soragna@gmail.com> Co-authored-by: Jeffery Hsu <jefferyyjhsu@gmail.com> Co-authored-by: bpwilcox <bpwonline28@gmail.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@gmail.com> Co-authored-by: Alexis Pojomovsky <apojomovsky@ekumenlabs.com>
This PR addresses a bug in the EventsExecutor related to timers. The issue occurs when multiple timers are present in the entities collection, and at least one of them gets re-initialized. Prior to this fix, the collection failed to detect which timers were re-initialized, leading to the following problems:
The fix consists in invoking the
remove_expired_entitiesright before the timers collection is updated.A regression test was included among the changes, this test will fail with the current rolling HEAD.