1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-40674 Include the checksum for non-corrupted Unknown events

This commit reörders code so the checksum is populated after
`mariadb-binlog --force` generates `Unknown_log_event` substitutes.
Previously, `mariadb-binlog --force` inconsistently omitted those
checksums from the output even if the checksum is presumably  usable.

After merging to 11.4 (MDEV-31273), this commit will also fix «
MDEV-40542 MSAN use-of-uninitialized-value on Unknown_log_event::read_checksum_alg
», which was exposed by MDEV-31273’s removal
of the base `Log_event::checksum_alg` field.

Reviewed-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
ParadoxV5
2026-08-07 20:43:51 -06:00
parent 52a2bc27cc
commit e383fb0f4e
3 changed files with 47 additions and 11 deletions

View File

@@ -0,0 +1,6 @@
CREATE TABLE t (a INT);
INSERT INTO t VALUES (0);
DROP TABLE t;
FLUSH BINARY LOGS;
#mariadb_binlog --debug=d,corrupt_table_map_colcnt_read --start-position=#binlog_start --stop-position=#binlog_stop #binlog_file 2>&1
FOUND 1 /CRC32 0x[[:xdigit:]]{8}.*\n# [Uu]nknown [Ee]vent/ in unknown_log_event.sql

View File

@@ -0,0 +1,29 @@
# MDEV-40674: Test `mariadb-binlog --force`'s Unknown event output
#
# Also: MDEV-40542
# MSAN use-of-uninitialized-value on Unknown_log_event::read_checksum_alg
--source include/have_debug.inc
--source include/have_binlog_format_row.inc # Testing with Table Map event
# Setup
CREATE TABLE t (a INT);
--let $binlog_file= query_get_value(SHOW BINLOG STATUS, File, 1)
--let $binlog_start= query_get_value(SHOW BINLOG STATUS, Position, 1)
# Generate an invalid Table Map event followed by an otherwise-valid Rows Event
INSERT INTO t VALUES (0);
--let $binlog_stop= query_get_value(SHOW BINLOG STATUS, Position, 1)
DROP TABLE t;
FLUSH BINARY LOGS;
--let SEARCH_FILE= $MYSQLTEST_VARDIR/tmp/unknown_log_event.sql
--let SEARCH_PATTERN= CRC32 0x[[:xdigit:]]{8}.*\\n# [Uu]nknown [Ee]vent
--let $mariadb_binlog= $MYSQL_BINLOG --result-file=$SEARCH_FILE --verify-binlog-checksum --force-read
--let $binlog_file= `SELECT CONCAT(@@datadir, '/$binlog_file')`
--echo #mariadb_binlog --debug=d,corrupt_table_map_colcnt_read --start-position=#binlog_start --stop-position=#binlog_stop #binlog_file 2>&1
--exec $mariadb_binlog --debug=d,corrupt_table_map_colcnt_read --start-position=$binlog_start --stop-position=$binlog_stop $binlog_file 2>&1
--source include/search_pattern_in_file.inc

View File

@@ -1113,8 +1113,9 @@ Log_event* Log_event::read_log_event(const uchar *buf, uint event_len,
*error= "Event crc check failed! Most likely there is event corruption.";
if (force_opt)
{
event_len-= BINLOG_CHECKSUM_LEN;
ev= new Unknown_log_event(buf, fdle);
DBUG_RETURN(ev);
goto exit;
}
else
DBUG_RETURN(NULL);
@@ -1330,16 +1331,6 @@ Log_event* Log_event::read_log_event(const uchar *buf, uint event_len,
}
exit:
if (ev)
{
ev->checksum_alg= alg;
#ifdef MYSQL_CLIENT
if (ev->checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
ev->checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
ev->crc= uint4korr(buf + (event_len));
#endif
}
DBUG_PRINT("read_event", ("%s(type_code: %u; event_len: %u)",
ev ? ev->get_type_str() : "<unknown>",
(uchar)buf[EVENT_TYPE_OFFSET],
@@ -1374,6 +1365,16 @@ exit:
DBUG_RETURN(0);
#endif
}
if (ev)
{
ev->checksum_alg= alg;
#ifdef MYSQL_CLIENT
if (ev->checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
ev->checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
ev->crc= uint4korr(buf + (event_len));
#endif
}
DBUG_RETURN(ev);
}