-
Notifications
You must be signed in to change notification settings - Fork 255
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
Add ".active" suffix to actively recording files #1672
base: rolling
Are you sure you want to change the base?
Conversation
facontidavide
commented
May 23, 2024
•
edited by MichaelOrlov
Loading
edited by MichaelOrlov
- Add the suffix ".active" to SequentialWriter::format_storage_uri
- When storage_ is closed, rename the file to remove the ".active" suffix.
- Closes Mark bags that are still being recorded #1597
Signed-off-by: Davide Faconti <[email protected]>
7d888fe
to
c18724d
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.
thank you for the PR, a few minor comments.
Co-authored-by: Tomoya Fujita <[email protected]> Signed-off-by: Davide Faconti <[email protected]>
@fujitatomoya thanks for the feedback! |
any additional concern blocking this PR? |
@tonynajjar If you have the ability to incorporate this change into your workspace you can give this a try as a fix for #1597 |
Thanks for the ping @defunctzombie and thanks for the fix @facontidavide. I'm on humble so after fixing some conflicts in the backport I was able to build. I also tested it out and looks like it works well (at least my humble backport does):
|
One comment though, the suffix is now 1- It was like that in ROS1 |
@tonynajjar , that was my original intentions, but since the suffix is added by the storage plugins, that would require more changes in multiple files |
That is why the solution with creating a temporary empty file with the same name as the original currently recording file but with the |
@facontidavide As regards
Yes. it doesn't handle properly cases when enabled file compression. |
I disagree that it is "better". It may be technically easier to implement because of other architectural choices in the code but I would not define it as "better" from an end-user standpoint. (My opinion of course). |
Signed-off-by: Davide Faconti <[email protected]>
ae57953
to
ef4e37b
Compare
Ok, based on the input (thanks!) I decided to address this in the individual storage plugins and it seems to work correctly, also when using file compression. All the changes to sequential writer have been reverted. |
Signed-off-by: Michael Orlov <[email protected]>
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.
@facontidavide Thanks for your contribution.
The approach with changes in the storage plugins looks more clear.
Although, it causes multiple failures in unit tests from various rosbag2 packages.
I've tried to fix linter issues and expectations in failing tests. However, It would be good to have a dedicated unit test in the rosbag2_storage
package to make sure that all plugins adhere the same behavior and also make sure that .active
will be removed after closing read_write
storage.
Also, need to consider if we want to add the same .active
suffix when we are openning storage with append
mode. Not sure what would be an implication from that and if we do really need it.
cc: @defunctzombie Opinion about append
mode and .active
suffix?
When does this happen? Is this when someone uses the rosbag2 interfaces as a library to read/update files in some "offline" workflows? Or does this also happen if you start/stop the recording process in some particular way? My perspective is that the If there is a way to start the recording process and tell it to append to an existing file if one exists (rather than start a new one) I am not sure what to think about that because the existing file may have already been copied elsewhere by the user so modifying it is kind of asking for strangeness with what it might mean for managing recordings on and off robot. If I had to be more principled about what should happen I would say that if the writer has updated the file on-disk to something that has now made it an invalid file (i.e in MCAP removed the footer, etc) then it would be appropriate to mark as |
@defunctzombie We actually don't have a real use case in rosbag2 for using storage in Ok, let's keep By the way, it seems we don't really support |
Another possibility is to add a get_storage_extension method to storage_interfaces::ReadWriteInterface, and have the storage plugin expect the full path including the extension. Like you're suggesting, I have used a separate file on the side with a different extension (.lock). In practice, there's some difference, because if the file is closed improperly all scripts that currently look for files ending with .mcap or .db3 now also have to also look for .active. |
@MichaelOrlov thanks a lot for turning CI green! Since we said that changes to support "append" are not required yet, is there anything blocking this? |
@facontidavide as regards
After some more investigation and weighting all the pros and cons, I am actually seriously considering closing this PR as wouldn't be merged in favor of the alternative approach of creating a temporary empty file with the same name as the original currently recording file but with the I am still not convinced that the current approach is better than alternative with creating a new empty file with Pros and cons of the current approach from this PR with direct file renaming.Pros:
Cons:
The scripts that are looking for the finished files will take the Pros and cons of the approach of creating a temporary empty file with the same name as the original currently recording but with the .active extension.Pros:
Cons:
|
I kind of proposed a similar thing (an However, your proposal by keeping the same name with a suffix actually mitigates that. So seems like a feasible plan. One note: how will this file be cleaned up in case of crashes? It might stay there forever and syncing scripts might always assume it's being written. Although this can of course be scripted around pragmatically. |
@Timple As regards your comment
Well, this is a corner case, which is a challenge for both approaches. |
Sooo... Shal we consider again the option of Linux file locks, then? Note that they are not mutually exclusive. It should technically work, even if people don't "see" that as they would with the "active" extension. |
@facontidavide As regards
The rosbag2 is one of the core packages, and we need to support Windows as well. I think that Linux file locks would be out of scope for consideration. |
I believe Windows have that too. |
Won't the file next to the bag file being recorded have the same bag split suffix? E.g. HHMMSS_mmss_0.active, HHMMSS_mmss_1.active, and so on? |
I have no need for this currently, but should it also support network shares (e.g., NFS, SMB)? Because I think that may complicate things even if there is OS support on both Linux and Windows for local files. |
As regards:
Yes, it is going to be |
thanks to all comments and information.
this looks really problematic for user... i think we need to avoid this for sure. but this also looks like it comes from current implementation details. if we can keep the and i think requirement here is to keep the notice for the user
just checking, during recording we can see 2 files, the one is in the file system (linux, no idea about windows), when we rename it, we can reuse the same inode without having any temporary one. but creating temporary file generates extra inode to be overwritten. i do not think this is the problem, but wanted to mentioned this because we would use |
Can you provide a reference for this pattern being used in some other software? I've never heard of it. On the other hand, the |