Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
Q2/2026 Server Maintenance
Description
Replay for failed multi-table deletes differs between mariadb-binlog and the slave. The slave has extra logic to continue replication without error if the multi-table delete fails, e.g. if it is aborted in the middle. See mysql_execute_command from sql_parse.cc:
/* |
If we are a slave, we should add IF EXISTS if the query executed
|
on the master without an error. This will help a slave to
|
recover from multi-table DROP TABLE that was aborted in the
|
middle.
|
*/
|
if ((thd->slave_thread && !thd->slave_expected_error && |
slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) ||
|
thd->variables.option_bits & OPTION_IF_EXISTS)
|
lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
|
However, the replay via mariadb-binlog does not enter this block, as thd->slave_thread is not set, and will thereby result in an error. See the following test case to reproduce:
--source include/have_innodb.inc
|
--source include/have_binlog_format_row.inc
|
--source include/master-slave.inc
|
|
|
--echo # Setup tables
|
--connection master
|
create table t1 (a int);
|
--error ER_BAD_TABLE_ERROR
|
drop table t1, t2;
|
--source include/save_master_gtid.inc
|
|
|
--echo # Replication continues without error..
|
--connection slave
|
--source include/sync_with_master_gtid.inc
|
--let $status_items=Last_SQL_Error,Last_IO_Error
|
--source include/show_slave_status.inc
|
|
|
--echo # t1 should have been dropped
|
--error ER_NO_SUCH_TABLE
|
select * from t1;
|
|
|
--echo #
|
--echo # mariadb-binlog replay use-case
|
|
|
--echo # Tagging binlog name
|
--connection master
|
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
|
--let $datadir=`select @@datadir`
|
|
|
|
|
--echo # Prepare slave for binlog replay
|
--connection slave
|
--source include/stop_slave.inc
|
|
|
--echo # Replay binlog on slave (results in error)
|
--echo # MYSQL_BINLOG datadir/binlog_file | MYSQL_SLAVE
|
--exec $MYSQL_BINLOG $datadir/$binlog_file | $MYSQL_SLAVE
|
which results in error
ERROR 1051 (42S02) at line 46: Unknown table 'test.t2'
|
mysqltest: At line 37: exec of ...
|
Output from before failure:
|
# MYSQL_BINLOG datadir/binlog_file | MYSQL_SLAVE
|
Attachments
Issue Links
- is caused by
-
MDEV-37602 Mariadb-binlog Replay Should Always Invoke Slave Applier Path
-
- Stalled
-