mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-40545 mariadb-binlog --force-read loops on truncated events
What was wrong: With --force-read, Log_event::read_log_event() returned a synthetic "Encrypted event" (Unknown_log_event) for every read error. A truncated event is such an error, so mariadb-binlog printed a fake event instead of stopping, and on most truncated binlogs it then never stopped at all. How it is fixed: The synthetic event is meant for encrypted events that mariadb-binlog cannot decrypt (MDEV-11319). It is now returned only for a decryption failure. Other read errors, like a truncated event or an out of memory error, are critical: continuing after them cannot produce meaningful output, so they are reported and mariadb-binlog stops as it does without --force-read. How it is tested: main.mysqlbinlog_force_read_truncated reads two truncated binlogs from std_data, one with a truncated event header and one with a truncated event body. The test loops forever without the fix.
This commit is contained in:
18
mysql-test/main/mysqlbinlog_force_read_truncated.result
Normal file
18
mysql-test/main/mysqlbinlog_force_read_truncated.result
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# MDEV-40545: --force-read must not loop on a truncated event
|
||||
#
|
||||
# The event header is truncated
|
||||
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
|
||||
/*!40019 SET @@session.max_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
DELIMITER /*!*/;
|
||||
ERROR: Error in Log_event::read_log_event(): 'Event truncated'
|
||||
ERROR: Could not read entry at offset 4: Error in log format or read error.
|
||||
# The event body is truncated
|
||||
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
|
||||
/*!40019 SET @@session.max_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
DELIMITER /*!*/;
|
||||
ERROR: Error in Log_event::read_log_event(): 'Event truncated', data_len: 94, event_type: 15
|
||||
ERROR: Could not read entry at offset 4: Error in log format or read error.
|
||||
# End of 11.4 tests
|
||||
13
mysql-test/main/mysqlbinlog_force_read_truncated.test
Normal file
13
mysql-test/main/mysqlbinlog_force_read_truncated.test
Normal file
@@ -0,0 +1,13 @@
|
||||
--echo #
|
||||
--echo # MDEV-40545: --force-read must not loop on a truncated event
|
||||
--echo #
|
||||
|
||||
--echo # The event header is truncated
|
||||
--error 1
|
||||
--exec $MYSQL_BINLOG --short-form --force-read $MYSQL_TEST_DIR/std_data/truncated_binlog_header.000001 2>&1
|
||||
|
||||
--echo # The event body is truncated
|
||||
--error 1
|
||||
--exec $MYSQL_BINLOG --short-form --force-read $MYSQL_TEST_DIR/std_data/truncated_binlog_body.000001 2>&1
|
||||
|
||||
--echo # End of 11.4 tests
|
||||
BIN
mysql-test/std_data/truncated_binlog_body.000001
Normal file
BIN
mysql-test/std_data/truncated_binlog_body.000001
Normal file
Binary file not shown.
BIN
mysql-test/std_data/truncated_binlog_header.000001
Normal file
BIN
mysql-test/std_data/truncated_binlog_header.000001
Normal file
Binary file not shown.
@@ -935,6 +935,10 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, int *out_error,
|
||||
error= "Event too big";
|
||||
goto err;
|
||||
case LOG_READ_DECRYPT:
|
||||
#ifdef MYSQL_CLIENT
|
||||
if (force_opt)
|
||||
DBUG_RETURN(new Unknown_log_event());
|
||||
#endif
|
||||
error= "Event decryption failure";
|
||||
goto err;
|
||||
case LOG_READ_CHECKSUM_FAILURE:
|
||||
@@ -956,11 +960,6 @@ err:
|
||||
if (unlikely(error))
|
||||
{
|
||||
DBUG_ASSERT(!res);
|
||||
#ifdef MYSQL_CLIENT
|
||||
if (force_opt)
|
||||
DBUG_RETURN(new Unknown_log_event());
|
||||
#endif
|
||||
|
||||
/*
|
||||
The SQL slave thread will check *out_error to know
|
||||
if there was an I/O error. Even if there is no "low-level" I/O errors
|
||||
|
||||
Reference in New Issue
Block a user