diff --git a/mysql-test/main/mysqlbinlog_force_read_truncated.result b/mysql-test/main/mysqlbinlog_force_read_truncated.result new file mode 100644 index 0000000000000..c61b2d1dc2641 --- /dev/null +++ b/mysql-test/main/mysqlbinlog_force_read_truncated.result @@ -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 diff --git a/mysql-test/main/mysqlbinlog_force_read_truncated.test b/mysql-test/main/mysqlbinlog_force_read_truncated.test new file mode 100644 index 0000000000000..dde1747ac8709 --- /dev/null +++ b/mysql-test/main/mysqlbinlog_force_read_truncated.test @@ -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 diff --git a/mysql-test/std_data/truncated_binlog_body.000001 b/mysql-test/std_data/truncated_binlog_body.000001 new file mode 100644 index 0000000000000..ba231a91034f2 Binary files /dev/null and b/mysql-test/std_data/truncated_binlog_body.000001 differ diff --git a/mysql-test/std_data/truncated_binlog_header.000001 b/mysql-test/std_data/truncated_binlog_header.000001 new file mode 100644 index 0000000000000..c0917e96d8b32 Binary files /dev/null and b/mysql-test/std_data/truncated_binlog_header.000001 differ diff --git a/sql/log_event.cc b/sql/log_event.cc index 9e01ee66bc463..5cfd2818083ee 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, int *out_error, 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