Skip to content

Propagate "custom_data" and "ros_distro" in to the metadata.yaml file during re-indexing #1700

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

Merged
merged 6 commits into from
Jun 12, 2024

Conversation

coalman321
Copy link
Contributor

Propagates the custom_data and ros_distro fields from the underlying storage into the metadata.yaml file during re-indexing.

  • Previously this data was not extracted from the storage and the subsequent fields in metadata.yaml were left as default.
  • The implementation in this PR uses the custom_data and ros_distro metadata from the newest storage file contained within the log as custom data can be modified in the storage API between successive split files.

This fixes #1699

@coalman321 coalman321 requested a review from a team as a code owner June 7, 2024 04:05
@coalman321 coalman321 requested review from gbiggs and hidmic and removed request for a team June 7, 2024 04:05
Signed-off-by: Cole Tucker

Signed-off-by: coalman321 <[email protected]>
Signed-off-by: coalman321 <[email protected]>
Copy link
Contributor

@fujitatomoya fujitatomoya left a 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

@MichaelOrlov MichaelOrlov changed the title [Jazzy] Propagate custom data and ros_distro during reindexing Propagate "custom_data" and "ros_distro" in to the metadata.yaml file during re-indexing Jun 7, 2024
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@coalman321 Thanks for the PR. Overall looks good to me.
However, I have a proposal to check if temp_metadata.custom_data is not empty before assigning it to the metadata_.custom_data and the same for the ros_distro.

@coalman321
Copy link
Contributor Author

@coalman321 Thanks for the PR. Overall looks good to me. However, I have a proposal to check if temp_metadata.custom_data is not empty before assigning it to the metadata_.custom_data and the same for the ros_distro.

So I changed my thoughts on implementation a few times during this PR. My guiding thought was that the youngest split file (most recent) should be the most up to date version of custom_data. I was concerned about the case where the user had edited the info between the split files and having any sort of filtering could cause the re-indexed data to not reflect this updated state. The metadata in the final split file written should already be an aggregation of this information by nature of the storage implementation and thus be the most "accurate" representation of the information the user intends to store. In my thought this extends to being empty as well.

If you think this thought process doesn't match up with the designed intent, then I would be happy to modify it.

@MichaelOrlov
Copy link
Contributor

@coalman321 Your assumption that the latest metadata should have the most up to date version of the custom_data is correct.
However, this is true for generic normal workflow. Although it might not be true if recording finishes abnormally, the metadata record could get corrupted or be incomplete.
IMO, it wouldn't hurt to add a sanity check that temp_metadata.custom_data is not empty before copying from it for a worst-case scenario.

@coalman321
Copy link
Contributor Author

I had not considered the abnormal case where the recording is not closed properly. Ill adjust the logic to work only if the fields are not empty.

@coalman321 coalman321 requested a review from MichaelOrlov June 11, 2024 17:17
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@coalman321 Thank you for your contribution.
LGTM with green CI.

@coalman321
Copy link
Contributor Author

@coalman321 Thank you for your contribution. LGTM with green CI.

Happy to help. Also looks like ament_cppcheck failed, but Github cant show status for it. It might just need to be re-run.

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@coalman321 May I ask you to modify https://github.com/ros2/rosbag2/blob/rolling/rosbag2_tests/test/rosbag2_tests/test_reindexer.cpp tests to check custom_data and ROS_DISTRO in the reindexer test?

@coalman321
Copy link
Contributor Author

@coalman321 May I ask you to modify https://github.com/ros2/rosbag2/blob/rolling/rosbag2_tests/test/rosbag2_tests/test_reindexer.cpp tests to check custom_data and ROS_DISTRO in the reindexer test?

Added verification for both in the reindexer test as requested.

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@coalman321 Thanks for updating the tests.
LGTM with green CI.

@MichaelOrlov
Copy link
Contributor

Pulls: #1700
Gist: https://gist.githubusercontent.com/MichaelOrlov/23b7ed7f99ad70b70f6d33a8bc52b264/raw/ffe2b74684675f2ba3d508aeae04d238473dce94/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_cpp rosbag2_tests
TEST args: --packages-above rosbag2_cpp rosbag2_tests
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/14060

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@MichaelOrlov
Copy link
Contributor

@coalman321 Unfortunately the CI failed on Windows with the following errors:

C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp(194,55): error C2678: binary '<': no operator found which takes a left-hand operand of type 'std::chrono::system_clock::time_point' (or there is no acceptable conversion) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\system_error(191,28): message : could be 'bool std::operator <(const std::error_code &,const std::error_code &) noexcept' [found using argument-dependent lookup] (compiling source file C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\system_error(277,28): message : or       'bool std::operator <(const std::error_condition &,const std::error_condition &) noexcept' [found using argument-dependent lookup] (compiling source file C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp(194,55): message : while trying to match the argument list '(std::chrono::system_clock::time_point, std::chrono::time_point<std::chrono::steady_clock,std::chrono::nanoseconds>)' [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp(195,53): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::chrono::time_point<std::chrono::steady_clock,std::chrono::nanoseconds>' (or there is no acceptable conversion) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

@coalman321
Copy link
Contributor Author

@coalman321 Unfortunately the CI failed on Windows with the following errors:

C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp(194,55): error C2678: binary '<': no operator found which takes a left-hand operand of type 'std::chrono::system_clock::time_point' (or there is no acceptable conversion) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\system_error(191,28): message : could be 'bool std::operator <(const std::error_code &,const std::error_code &) noexcept' [found using argument-dependent lookup] (compiling source file C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\system_error(277,28): message : or       'bool std::operator <(const std::error_condition &,const std::error_condition &) noexcept' [found using argument-dependent lookup] (compiling source file C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp(194,55): message : while trying to match the argument list '(std::chrono::system_clock::time_point, std::chrono::time_point<std::chrono::steady_clock,std::chrono::nanoseconds>)' [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

C:\ci\ws\src\coalman321\rosbag2\rosbag2_cpp\src\rosbag2_cpp\reindexer.cpp(195,53): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::chrono::time_point<std::chrono::steady_clock,std::chrono::nanoseconds>' (or there is no acceptable conversion) [C:\ci\ws\build\rosbag2_cpp\rosbag2_cpp.vcxproj]

Looks like it was an issue with the clock type that was being used. GCC must alias the system clock and the high-res clock in chrono. The change uses the exact same time point spec from the BagMetadata structure now.

@MichaelOrlov
Copy link
Contributor

  • Re-run Windows CI job
  • Windows Build Status

@MichaelOrlov MichaelOrlov merged commit 804432c into ros2:rolling Jun 12, 2024
@MichaelOrlov
Copy link
Contributor

https://github.com/Mergifyio backport jazzy iron

Copy link

mergify bot commented Jun 12, 2024

mergify bot pushed a commit that referenced this pull request Jun 12, 2024
… during re-indexing (#1700)

* propagate custom data and ros_distro during reindexing
Signed-off-by: Cole Tucker

Signed-off-by: coalman321 <[email protected]>

* fix ament uncrustify issue

Signed-off-by: coalman321 <[email protected]>

* only update metadata if size is nonzero

Signed-off-by: coalman321 <[email protected]>

* fix uncrustify issue and switch to empty

Signed-off-by: coalman321 <[email protected]>

* update reindexer test to verify custom data and ros_distro changes

Signed-off-by: coalman321 <[email protected]>

* Convert to use exact clock type for windows CI

Signed-off-by: coalman321 <[email protected]>

---------

Signed-off-by: coalman321 <[email protected]>
(cherry picked from commit 804432c)
mergify bot pushed a commit that referenced this pull request Jun 12, 2024
… during re-indexing (#1700)

* propagate custom data and ros_distro during reindexing
Signed-off-by: Cole Tucker

Signed-off-by: coalman321 <[email protected]>

* fix ament uncrustify issue

Signed-off-by: coalman321 <[email protected]>

* only update metadata if size is nonzero

Signed-off-by: coalman321 <[email protected]>

* fix uncrustify issue and switch to empty

Signed-off-by: coalman321 <[email protected]>

* update reindexer test to verify custom data and ros_distro changes

Signed-off-by: coalman321 <[email protected]>

* Convert to use exact clock type for windows CI

Signed-off-by: coalman321 <[email protected]>

---------

Signed-off-by: coalman321 <[email protected]>
(cherry picked from commit 804432c)
@MichaelOrlov
Copy link
Contributor

https://github.com/Mergifyio backport humble

Copy link

mergify bot commented Jun 12, 2024

backport humble

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jun 12, 2024
… during re-indexing (#1700)

* propagate custom data and ros_distro during reindexing
Signed-off-by: Cole Tucker

Signed-off-by: coalman321 <[email protected]>

* fix ament uncrustify issue

Signed-off-by: coalman321 <[email protected]>

* only update metadata if size is nonzero

Signed-off-by: coalman321 <[email protected]>

* fix uncrustify issue and switch to empty

Signed-off-by: coalman321 <[email protected]>

* update reindexer test to verify custom data and ros_distro changes

Signed-off-by: coalman321 <[email protected]>

* Convert to use exact clock type for windows CI

Signed-off-by: coalman321 <[email protected]>

---------

Signed-off-by: coalman321 <[email protected]>
(cherry picked from commit 804432c)

# Conflicts:
#	rosbag2_tests/test/rosbag2_tests/test_reindexer.cpp
MichaelOrlov pushed a commit that referenced this pull request Jun 13, 2024
… during re-indexing (#1700) (#1710)

* propagate custom data and ros_distro during reindexing
Signed-off-by: Cole Tucker

Signed-off-by: coalman321 <[email protected]>

* fix ament uncrustify issue

Signed-off-by: coalman321 <[email protected]>

* only update metadata if size is nonzero

Signed-off-by: coalman321 <[email protected]>

* fix uncrustify issue and switch to empty

Signed-off-by: coalman321 <[email protected]>

* update reindexer test to verify custom data and ros_distro changes

Signed-off-by: coalman321 <[email protected]>

* Convert to use exact clock type for windows CI

Signed-off-by: coalman321 <[email protected]>

---------

Signed-off-by: coalman321 <[email protected]>
(cherry picked from commit 804432c)

Co-authored-by: Cole Tucker <[email protected]>
MichaelOrlov pushed a commit that referenced this pull request Jun 23, 2024
…ml file during re-indexing (backport #1700) (#1711)

* Propagate "custom_data" and "ros_distro" in to the metadata.yaml file during re-indexing (#1700)

* propagate custom data and ros_distro during reindexing
Signed-off-by: Cole Tucker

Signed-off-by: coalman321 <[email protected]>

* fix ament uncrustify issue

Signed-off-by: coalman321 <[email protected]>

* only update metadata if size is nonzero

Signed-off-by: coalman321 <[email protected]>

* fix uncrustify issue and switch to empty

Signed-off-by: coalman321 <[email protected]>

* update reindexer test to verify custom data and ros_distro changes

Signed-off-by: coalman321 <[email protected]>

* Convert to use exact clock type for windows CI

Signed-off-by: coalman321 <[email protected]>

---------

Signed-off-by: coalman321 <[email protected]>
(cherry picked from commit 804432c)

* Remove "metadata.ros_distro" update since we don't have in on Iron

Signed-off-by: Michael Orlov <[email protected]>

* Skip check for `custom_metadata` in test for mcap storage plugin.

- Rationale:
Mcap storage doesn't store serialized metadata in bag directly on Iron
and Humble. Backporting of the relevant #1423 is not possible without
updating mcap vendor package to the v1.1.0 because we have dependencies
from the mcap_reader_->metadataIndexes(); API which became available
only in the foxglove/mcap#902

Signed-off-by: Michael Orlov <[email protected]>

---------

Signed-off-by: Michael Orlov <[email protected]>
Co-authored-by: Cole Tucker <[email protected]>
Co-authored-by: Michael Orlov <[email protected]>
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.

Reindexing fails to read custom_data and ros_distro from storage
3 participants