Skip to content

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
event_manual_construction
Mar 4, 2026
Merged

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
percona-ysorokin merged 1 commit intomainfrom
event_manual_construction

Conversation

@percona-ysorokin
Copy link
Collaborator

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.

…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.
@percona-ysorokin percona-ysorokin merged commit 8b89f52 into main Mar 4, 2026
7 checks passed
@percona-ysorokin percona-ysorokin deleted the event_manual_construction branch March 5, 2026 00:46
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.

1 participant