Skip to content
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 race condition in transport recorder #303

Merged

Conversation

carlossvg
Copy link
Contributor

This PR fixes a race condition when creating a topic in robasg2 transport recorder.

Sometimes test_rosbag2_record_end_to_end fails by timeout with the following error messages:

1: [ERROR] [rosbag2_transport]: Failed to record: Topic '/test_topic' has not been created yet! Call 'create_topic' first

Signed-off-by: Carlos San Vicente carlos.sanvicente@apex.ai

Signed-off-by: Carlos San Vicente <carlos.sanvicente@apex.ai>
@emersonknapp
Copy link
Collaborator

emersonknapp commented Feb 28, 2020

Thanks for the contribution!

Can you think of a way to add a regression test for this fix?

Also, please a comment in the code for why this order of operations is necessary.

@MichaelOrlov
Copy link
Contributor

Hi Emerson @emersonknapp,
I am actually author of this fix in Apex.AI.
What kind of regression tests you are requesting? Can you please elaborate?
This is fix for race condition. I am kind of confused about your request. If somebody will try to add some unit test to make sure that there no race conditions it will be non deterministic and will fail from time to time or test nothing.
If you have idea how to properly write such a test - please let us know.

As regarding to explanation of why this order of operation is necessary:
We need to create topic in writer before we are trying to create subscription. Since in callback for subscription we are calling writer_->write(bag_message); and it could happened that callback called before we reached out the line: writer_->create_topic(topic)

@emersonknapp
Copy link
Collaborator

If it's too hard then that's ok, but I want to make sure we've always at least thought through regression tests for fixes, and it's good to note that thought process out in the open either way.

Can you please add that comment to the code itself? That way the next implementer to change that is better informed.

@MichaelOrlov
Copy link
Contributor

Sure, we will add comments about it in code.

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
@MichaelOrlov MichaelOrlov force-pushed the fix-race-condition-in-transport-recorder branch from 8aeb93d to 4432d6b Compare March 2, 2020 22:19
@MichaelOrlov
Copy link
Contributor

Hi @emersonknapp Can you please kindly review/approve this changes. I've added comment about importance of order of operations.

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for pinging me again, I can lose updates sometimes

@emersonknapp emersonknapp merged commit dc364ae into ros2:master Mar 9, 2020
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.

3 participants