PS-10246 feature: Implement fixing next_event_position fields / checksums in the event common_header / footer in case of reconnecting to another node (part 3)#98
Merged
percona-ysorokin merged 1 commit intomainfrom Mar 4, 2026
Conversation
…sums in the event common_header / footer in case of reconnecting to another node (part 3) https://perconadev.atlassian.net/browse/PS-10246 Added ability to construct binlog events manually from components (common header, post-header, and body). The footer (with the calculated checksum) is added upon request. As a side effect the same event creation function 'binsrv::events::event::create_event()' can also create an encoded version of this event. In order to achieve this, individual event components can now also be constructed from the individual values of their fields: - 'common_header' - 'footer' - generic_post_header_impl<code_type::rotate> - generic_body_impl<code_type::rotate> - generic_post_header_impl<code_type::format_description> - generic_body_impl<code_type::format_description> - generic_post_header_impl<code_type::previous_gtids_log> - generic_body_impl<code_type::previous_gtids_log> In addition, added 'calculate_encoded_size()' / 'encode_to()' methods along with equality comparison operators for each of those classes / template specializations. Added 'binsrv::events::events_storage' typedef based on the 'boost::container::small_vector' as a recommended buffer type for event encoding. 'reader_context::get_hardcoded_post_header_lengths()' method made public in order to be able to construct FORMAT_DESCRIPTION event post headers. 'binsrv::ctime_timestamp' class can now generate readable timestamp in 2 formats: - Extended ISO via 'iso_extended_str()', 'e.g 2026-01-01T20:30:00'. - Simple via 'simple_str()', e.g '2026-Jan-01 20:30:00'. Added 'now()' method to return current timestamp. Added 'util::to_underlying()' helper function (similar to c++23 'std::to_underlying()') that helps with enum to underlying integral conversions. Added 'util::from_underlying()' helper function that helps with underlying integral to enum conversions. Added 'util::to_unsigned()' / 'util::to_signed()' helper functions which help with conversion integral values to its unsigned / signed counterparts of the same size. Fixed problem with not being able to use '|' / '&' / '^' binary operators for 'util::flag_set'. Added new test 'event_test' unit test (BOOST_TEST_MODULE EventTests) that checks roundtrip encoding / parsing functionality for ROTATE, FORMAT_DESCRIPTION, and PREVIOUS_GTIDS_LOG events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://perconadev.atlassian.net/browse/PS-10246
Added ability to construct binlog events manually from components (common header, post-header, and body). The footer (with the calculated checksum) is added upon request. As a side effect the same event creation function 'binsrv::events::event::create_event()' can also create an encoded version of this event.
In order to achieve this, individual event components can now also be constructed from the individual values of their fields:
In addition, added 'calculate_encoded_size()' / 'encode_to()' methods along with equality comparison operators for each of those classes / template specializations.
Added 'binsrv::events::events_storage' typedef based on the 'boost::container::small_vector' as a recommended buffer type for event encoding.
'reader_context::get_hardcoded_post_header_lengths()' method made public in order to be able to construct FORMAT_DESCRIPTION event post headers.
'binsrv::ctime_timestamp' class can now generate readable timestamp in 2 formats:
Added 'util::to_underlying()' helper function (similar to c++23 'std::to_underlying()') that helps with enum to underlying integral conversions. Added 'util::from_underlying()' helper function that helps with underlying integral to enum conversions.
Added 'util::to_unsigned()' / 'util::to_signed()' helper functions which help with conversion integral values to its unsigned / signed counterparts of the same size.
Fixed problem with not being able to use '|' / '&' / '^' binary operators for 'util::flag_set'.
Added new test 'event_test' unit test (BOOST_TEST_MODULE EventTests) that checks roundtrip encoding / parsing functionality for ROTATE, FORMAT_DESCRIPTION, and PREVIOUS_GTIDS_LOG events.