-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug that a callback not reached #1640
Fix bug that a callback not reached #1640
Conversation
d783577
to
52eba9a
Compare
this test case expects test result as
after using ros2/rmw_fastrtps#527, there is no failure. |
Before merging this test, can we discuss whether attaching a node to two different executors should be allowed by the API? This isn't currently a requirement AFAIK, so making this change is not trivial at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reexamined the test to check what @asorbini was asking about, and I think I found some flaws, but the general idea (i.e. using more than one executor per node via add_callback_group()
and having a callback group wake an executor when something is added to it in order to consider new items) is a supported use case based on the API.
It might be that this is a bug in rclcpp and not the middlewares however. I need to look more deeply at the root cause of the issue. But I don't have time at the moment.
This kind of test source code seems not good (adding it into rclcpp might make other users wrongly use it in the future), close it. |
i do not know why we need to close this. after |
I don't think we needed to close it, but I do think the things I pointed out needed to be addressed. I do not think, however, that we should have tests that copy user submitted code by including anti-patterns or otherwise not-recommended practices. Instead, the test should (ideally) test one potential issue at a time. It can be distilled from a user reported issue, but again it should be cleaned up and written as properly as possible. |
yeah okay that makes sense to me. |
reopen it after not using some anti-pattern source code. |
I have updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall, i think it looks good.
@wjwwood friendly ping. |
Noting that this is causing a bug in the Humble migration and this fixes it for an issue in Nav2 linked above @clalancette Obviously too late in the game for this to get into Humble out of the box, but hope that it will get in for the LTS and backported. The issues we ran into were very subtle. |
It looks like this needs a rebase, and another review for the latest changes. Once that is done, we can hopefully merge it in for Rolling. Backporting it to Humble is going to be tricky, as it changes ABI. We'll have to consider another way to do that. |
d7b1a74
to
6f8bd5e
Compare
@wjwwood friendly ping. |
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
… after shutdown Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chris Lalancette <[email protected]>
c50390c
to
8dd0ec8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased this PR and made a few minor changes (just to the include files).
Overall, I think the idea behind this PR is good, but I will point out that it is not thread-safe. In particular, the lock around get_notify_guard_condition
is useless; it is only held while manipulating the shared_ptr, but is then dropped when we return the object. Anything we do with that object afterwards is not thread-safe.
What I think we should do instead is to make sure we do any operations on the callback-group guard condition with the lock held. That would require us to add some additional APIs (like a new trigger
method), modify some of the existing ones (change destroy_notify_guard_condition
to only destroy the guard condition if it was created and not error out), and otherwise clean some things up. With those things done, we should be able to make this thread-safe and move forward with this.
One callback group can only have one notify_guard_condition_, the notify_guard_condition_mutex_ is jsut for these three operations, and the callback group can be used in only one executor. so it seems unnecessary to add extra mutex to make the callback-group guard condition thread-safe. |
make a callback group can only create one guard condition Signed-off-by: Chen Lihui <[email protected]>
…ack group Signed-off-by: Chen Lihui <[email protected]>
@iuhilnehc-ynos thanks for the effort on this, i will take a look at this today. I think this is very helpful for user application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
dependent and above CI all green, i will go ahead to merge this. |
@iuhilnehc-ynos i think we can backport this to humble, right? it would be really nice to backport since this affects user application behavior. |
@mergify backport this to humble Just create backport PR so that we will not forget, let's give it a couple of weeks to make sure there is no degression, then we can merge the backport PR to humble. |
❌ No backport have been created
|
* Add a test case a subscriber on a new executor with a callback group triggered to receive a message Signed-off-by: Chen Lihui <[email protected]> * fix flaky and not to use spin_some Signed-off-by: Chen Lihui <[email protected]> * update comment Signed-off-by: Chen Lihui <[email protected]> * update for not using anti-pattern source code Signed-off-by: Chen Lihui <[email protected]> * add a notify guard condition for callback group Co-authored-by: William Woodall <[email protected]> Signed-off-by: Chen Lihui <[email protected]> * Notify guard condition of Node not to be used in Executor it is only for the waitset of GraphListener Signed-off-by: Chen Lihui <[email protected]> * put code in the try catch Signed-off-by: Chen Lihui <[email protected]> * defer to create guard condition Signed-off-by: Chen Lihui <[email protected]> * use context directly for the create function Signed-off-by: Chen Lihui <[email protected]> * cpplint Signed-off-by: Chen Lihui <[email protected]> * fix that some case might call add_node after shutdown Signed-off-by: Chen Lihui <[email protected]> * nitpick and fix some potential bug Signed-off-by: Chen Lihui <[email protected]> * add sanity check as some case might not create notify guard condition after shutdown Signed-off-by: Chen Lihui <[email protected]> * Cleanup includes. Signed-off-by: Chris Lalancette <[email protected]> * remove destroy method make a callback group can only create one guard condition Signed-off-by: Chen Lihui <[email protected]> * remove limitation that guard condition can not be re-created in callback group Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chris Lalancette <[email protected]> Co-authored-by: William Woodall <[email protected]> Co-authored-by: Chris Lalancette <[email protected]> (cherry picked from commit d119157)
* Add a test case a subscriber on a new executor with a callback group triggered to receive a message Signed-off-by: Chen Lihui <[email protected]> * fix flaky and not to use spin_some Signed-off-by: Chen Lihui <[email protected]> * update comment Signed-off-by: Chen Lihui <[email protected]> * update for not using anti-pattern source code Signed-off-by: Chen Lihui <[email protected]> * add a notify guard condition for callback group Co-authored-by: William Woodall <[email protected]> Signed-off-by: Chen Lihui <[email protected]> * Notify guard condition of Node not to be used in Executor it is only for the waitset of GraphListener Signed-off-by: Chen Lihui <[email protected]> * put code in the try catch Signed-off-by: Chen Lihui <[email protected]> * defer to create guard condition Signed-off-by: Chen Lihui <[email protected]> * use context directly for the create function Signed-off-by: Chen Lihui <[email protected]> * cpplint Signed-off-by: Chen Lihui <[email protected]> * fix that some case might call add_node after shutdown Signed-off-by: Chen Lihui <[email protected]> * nitpick and fix some potential bug Signed-off-by: Chen Lihui <[email protected]> * add sanity check as some case might not create notify guard condition after shutdown Signed-off-by: Chen Lihui <[email protected]> * Cleanup includes. Signed-off-by: Chris Lalancette <[email protected]> * remove destroy method make a callback group can only create one guard condition Signed-off-by: Chen Lihui <[email protected]> * remove limitation that guard condition can not be re-created in callback group Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chris Lalancette <[email protected]> Co-authored-by: William Woodall <[email protected]> Co-authored-by: Chris Lalancette <[email protected]> (cherry picked from commit d119157) Co-authored-by: Chen Lihui <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
* Add a test case a subscriber on a new executor with a callback group triggered to receive a message Signed-off-by: Chen Lihui <[email protected]> * fix flaky and not to use spin_some Signed-off-by: Chen Lihui <[email protected]> * update comment Signed-off-by: Chen Lihui <[email protected]> * update for not using anti-pattern source code Signed-off-by: Chen Lihui <[email protected]> * add a notify guard condition for callback group Co-authored-by: William Woodall <[email protected]> Signed-off-by: Chen Lihui <[email protected]> * Notify guard condition of Node not to be used in Executor it is only for the waitset of GraphListener Signed-off-by: Chen Lihui <[email protected]> * put code in the try catch Signed-off-by: Chen Lihui <[email protected]> * defer to create guard condition Signed-off-by: Chen Lihui <[email protected]> * use context directly for the create function Signed-off-by: Chen Lihui <[email protected]> * cpplint Signed-off-by: Chen Lihui <[email protected]> * fix that some case might call add_node after shutdown Signed-off-by: Chen Lihui <[email protected]> * nitpick and fix some potential bug Signed-off-by: Chen Lihui <[email protected]> * add sanity check as some case might not create notify guard condition after shutdown Signed-off-by: Chen Lihui <[email protected]> * Cleanup includes. Signed-off-by: Chris Lalancette <[email protected]> * remove destroy method make a callback group can only create one guard condition Signed-off-by: Chen Lihui <[email protected]> * remove limitation that guard condition can not be re-created in callback group Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chris Lalancette <[email protected]> Co-authored-by: William Woodall <[email protected]> Co-authored-by: Chris Lalancette <[email protected]>
* Add a test case a subscriber on a new executor with a callback group triggered to receive a message Signed-off-by: Chen Lihui <[email protected]> * fix flaky and not to use spin_some Signed-off-by: Chen Lihui <[email protected]> * update comment Signed-off-by: Chen Lihui <[email protected]> * update for not using anti-pattern source code Signed-off-by: Chen Lihui <[email protected]> * add a notify guard condition for callback group Co-authored-by: William Woodall <[email protected]> Signed-off-by: Chen Lihui <[email protected]> * Notify guard condition of Node not to be used in Executor it is only for the waitset of GraphListener Signed-off-by: Chen Lihui <[email protected]> * put code in the try catch Signed-off-by: Chen Lihui <[email protected]> * defer to create guard condition Signed-off-by: Chen Lihui <[email protected]> * use context directly for the create function Signed-off-by: Chen Lihui <[email protected]> * cpplint Signed-off-by: Chen Lihui <[email protected]> * fix that some case might call add_node after shutdown Signed-off-by: Chen Lihui <[email protected]> * nitpick and fix some potential bug Signed-off-by: Chen Lihui <[email protected]> * add sanity check as some case might not create notify guard condition after shutdown Signed-off-by: Chen Lihui <[email protected]> * Cleanup includes. Signed-off-by: Chris Lalancette <[email protected]> * remove destroy method make a callback group can only create one guard condition Signed-off-by: Chen Lihui <[email protected]> * remove limitation that guard condition can not be re-created in callback group Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chen Lihui <[email protected]> Signed-off-by: Chris Lalancette <[email protected]> Co-authored-by: William Woodall <[email protected]> Co-authored-by: Chris Lalancette <[email protected]>
a subscriber on a new executor with a callback group triggered to receive a message
related to #1611
Signed-off-by: Chen Lihui [email protected]