-
Notifications
You must be signed in to change notification settings - Fork 249
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
Make snapshot writing into a new file each time it is triggered #1842
Conversation
- Note. Snapshot now became a blocking call and mutually exclusive with writer::write(message) method to avoid race conditions. i.e. blocking the same writer_mutex_ Signed-off-by: Michael Orlov <[email protected]>
74eceb0
to
24c824c
Compare
Co-authored-by: Clemens Mühlbacher <[email protected]> Signed-off-by: Michael Orlov <[email protected]>
Signed-off-by: Michael Orlov <[email protected]>
24c824c
to
f1c36b9
Compare
Signed-off-by: Michael Orlov <[email protected]>
Thank you for all the work on this feature. Looks very promising. And great news that it can be backported. As far as I can tell there should be no data races in there although, there will be several calls of write_messages function with an empty array. There is only one small remark: |
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.
from what I understand, the tests write messages into the cache, then trigger a single snapshot, and then validate everything.
I believe we should test that this works with more than 1 snapshot. Could we check the metadata too, e.g., starting_time
, duration
, and message_count
too?
rosbag2_compression/test/rosbag2_compression/test_sequential_compression_writer.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/test/rosbag2_compression/test_sequential_compression_writer.cpp
Show resolved
Hide resolved
I think this makes sense. |
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 with green CI, just one minor comment that does not block this PR.
Signed-off-by: Michael Orlov <[email protected]>
Signed-off-by: Michael Orlov <[email protected]>
@christophebedard I added a check for metadata in the test. To cover the case if snapshot could be called twice - I created a separate test case. @cmuehlbacher As regards
No it is not. I double-checked in debuuger and we have constraints in tests that write messages will be called only once per snapshot. As regards:
The reason why I use |
Signed-off-by: Michael Orlov <[email protected]>
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.
Looks good to me with green CI.
Pulls: #1842 |
https://github.com/Mergifyio backport jazzy humble |
✅ Backports have been created
|
* Make snapshot writing into a new file each time when it is triggered - Note. Snapshot now became a blocking call and mutually exclusive with writer::write(message) method to avoid race conditions. i.e. blocking the same writer_mutex_ Signed-off-by: Michael Orlov <[email protected]> * Add unit test to make sure that snapshot writing in the new file Co-authored-by: Clemens Mühlbacher <[email protected]> Signed-off-by: Michael Orlov <[email protected]> * Add support for snapshot with file compression Signed-off-by: Michael Orlov <[email protected]> * Rename newly added tests to avoid misunderstanding Signed-off-by: Michael Orlov <[email protected]> * Address review comments in tests Signed-off-by: Michael Orlov <[email protected]> * Change order of includes in the test_sequential_compression_writer.cpp Signed-off-by: Michael Orlov <[email protected]> * Update metadata_.message_count unconditionally in write_messages(..) Signed-off-by: Michael Orlov <[email protected]> --------- Signed-off-by: Michael Orlov <[email protected]> Co-authored-by: Clemens Mühlbacher <[email protected]> (cherry picked from commit 3f2281f)
* Make snapshot writing into a new file each time when it is triggered - Note. Snapshot now became a blocking call and mutually exclusive with writer::write(message) method to avoid race conditions. i.e. blocking the same writer_mutex_ Signed-off-by: Michael Orlov <[email protected]> * Add unit test to make sure that snapshot writing in the new file Co-authored-by: Clemens Mühlbacher <[email protected]> Signed-off-by: Michael Orlov <[email protected]> * Add support for snapshot with file compression Signed-off-by: Michael Orlov <[email protected]> * Rename newly added tests to avoid misunderstanding Signed-off-by: Michael Orlov <[email protected]> * Address review comments in tests Signed-off-by: Michael Orlov <[email protected]> * Change order of includes in the test_sequential_compression_writer.cpp Signed-off-by: Michael Orlov <[email protected]> * Update metadata_.message_count unconditionally in write_messages(..) Signed-off-by: Michael Orlov <[email protected]> --------- Signed-off-by: Michael Orlov <[email protected]> Co-authored-by: Clemens Mühlbacher <[email protected]> (cherry picked from commit 3f2281f)
Great! Thanks for this feature! |
This PR will make snapshot writing into a new file each time it is triggered.
Note. Snapshot now becomes a blocking call and mutually exclusive with the
writer::write(message)
method to avoid race conditions, i.e., blocking the samewriter_mutex_
.The
set_data_ready()
method from #1839 is not needed since "snapshot" has now become a blocking call; therefore, there are no race conditions, and we will not dump data from the cyclic buffer twice becausedata_ready
will be settled false after the first dump withmessage_cache_->notify_data_ready();
.rosbag2/rosbag2_cpp/src/rosbag2_cpp/cache/circular_message_cache.cpp
Lines 95 to 106 in 786c3c4
However, we still need to call
split_bagfile_local(true)
to trigger callbacks and open a new storage file.This PR could be backported. There are no API/ABI breaking changes in it.