-
Notifications
You must be signed in to change notification settings - Fork 240
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
Mutex around writer access in recorder #491
Conversation
Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
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.
Thanks for kicking this off. I am requesting changes here though for two reasons:
- I am not sure if
rosbag2_transport
is the right location to protect for concurrency. While this would certainly help for the command line interface, I think the right place is withinrosbag2_cpp
. - Call it premature optimization (I have to measure my claim first), but I would expect this to lead to other performance issues as the actual call to write can be blocked if (creating a subscription takes too long or many subscriptions are being created in a row). I am not 100% certain yet what the best way is but I would like to see the call to write basically being wait free.
Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
@Karsten1987 I added locking in the Do we need a similar thread-safe interface for the reader class? I have trouble imagining a use-case where you would read the from multiple threads with the current API (in particular the |
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 think this looks good to me. @emersonknapp any thoughts on this?
@Stapelzeiger please sign your commits to make the DCO bot happy.
This reverts commit 714141c. Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
3f0a88e
to
2e0586d
Compare
Any updates on this? Our system suffers from the bug described in #486, making it almost impossible to record our topics. Would be great to have this merged. |
@Stapelzeiger thanks for the contribution |
@adamdbrw fyi |
* Mutex around writer access in recorder Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * mutex in rosbag2_cpp writer for storage access Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * Revert "Mutex around writer access in recorder" This reverts commit 714141c. Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * alphabetical include order Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
* Mutex around writer access in recorder Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * mutex in rosbag2_cpp writer for storage access Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * Revert "Mutex around writer access in recorder" This reverts commit 714141c. Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * alphabetical include order Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
Hello! It would be great to backport this fix to Foxy. Can I do it myself according to the Guide ? |
* Mutex around writer access in recorder Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * mutex in rosbag2_cpp writer for storage access Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * Revert "Mutex around writer access in recorder" This reverts commit 714141c. Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * alphabetical include order Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com>
Yes, by all means. If the cherry-pick works without issue then it is an easy backport. |
* Mutex around writer access in recorder Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * mutex in rosbag2_cpp writer for storage access Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * Revert "Mutex around writer access in recorder" This reverts commit 714141c. Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> * alphabetical include order Signed-off-by: Patrick Spieler <stapelzeiger@gmail.com> Co-authored-by: Patrick Spieler <Stapelzeiger@gmail.com>
The storage plugins are not designed to be thread safe. The recorder must therefore use a mutex when accessing the writer from different contexts. This happens for topic creation during discovery as well as in message callbacks from subscribed topics.
This fixes #486 and #480.