diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2022-11-30 11:59:38 -0700 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2022-11-30 11:59:40 -0700 |
commit | b6c44e76ecdc8b391657776209a29e341e443281 (patch) | |
tree | c3d39fd4efb99380541b7bcc7856d28445dfb99f | |
parent | 7b44d0ba573c3a07d5fe8b43251c705ec1d63597 (diff) | |
download | mariadb-git-bb-10.5-MDEV-29981-log-headers.tar.gz |
MDEV-29981: Replica stops with 'Found invalid event in binary log'bb-10.5-MDEV-29981-log-headers
Prototype commit for a primary to print certain event's
headers before sending to replica to facilitate debugging
a release build. Specifically, it will output the header
of a fake rotate event, the following format description
event, and the next event.
-rw-r--r-- | sql/sql_repl.cc | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index decddba6c4f..77e512a6642 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -48,6 +48,28 @@ static int binlog_dump_count = 0; extern TYPELIB binlog_checksum_typelib; +/* + Helper function to print an event's header before sending it to a replica for + debugging a release build. +*/ +static void print_event_header(String *packet) +{ + char *ptr= packet->c_ptr_safe(); + sql_print_information("Header: %02x " /* Default reserved */ + "| %02x %02x %02x %02x " /* Timestamp */ + "| %02x " /* Type */ + "| %02x %02x %02x %02x " /* Master ID */ + "| %02x %02x %02x %02x " /* Size */ + "| %02x %02x %02x %02x " /* Master Pos */ + "| %02x %02x", /* Flags */ + ptr[0], /* Default reserved */ + ptr[1], ptr[2], ptr[3], ptr[4], /* Timestamp */ + ptr[5], /* Type */ + ptr[6], ptr[7], ptr[8], ptr[9], /* Master ID */ + ptr[10], ptr[11], ptr[12], ptr[13], /* Size */ + ptr[14], ptr[15], ptr[16], ptr[17], /* Master Pos */ + ptr[18], ptr[19]); /* Flags */ +} static int fake_event_header(String* packet, Log_event_type event_type, ulong extra_len, @@ -163,6 +185,8 @@ struct binlog_send_info { bool should_stop; size_t dirlen; + uint debug_event_header; + binlog_send_info(THD *thd_arg, String *packet_arg, ushort flags_arg, char *lfn) : thd(thd_arg), net(&thd_arg->net), packet(packet_arg), @@ -180,7 +204,8 @@ struct binlog_send_info { hb_info_counter(0), #endif clear_initial_log_pos(false), - should_stop(false) + should_stop(false), + debug_event_header(0) { error_text[0] = 0; bzero(&error_gtid, sizeof(error_gtid)); @@ -252,6 +277,13 @@ static int fake_rotate_event(binlog_send_info *info, ulonglong position, info->error= ER_UNKNOWN_ERROR; DBUG_RETURN(err); } + + if (global_system_variables.log_warnings > 2) + { + sql_print_information("Sending fake rotate event to replica with following header.."); + print_event_header(packet); + info->debug_event_header= 1; + } DBUG_RETURN(0); } @@ -2041,6 +2073,13 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type, return "run 'before_send_event' hook failed"; } + if (info->debug_event_header) + { + sql_print_information("Sending event to replica with following header.."); + print_event_header(packet); + info->debug_event_header= 0; + } + if (my_net_write(info->net, (uchar*) packet->ptr(), len)) { info->error= ER_UNKNOWN_ERROR; @@ -2401,6 +2440,12 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log, } } + if (info->debug_event_header) + { + sql_print_information("Sending Format Description Event to replica with following header.."); + print_event_header(packet); + } + /* send it */ if (my_net_write(info->net, (uchar*) packet->ptr(), packet->length())) { |