1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-31804 Assertion `thd->m_transaction_psi == __null' fails

... upon replicating online ALTER

When an online event is applied and slave_exec_mode is idempotent,
Write_rows_log_event::do_before_row_operations had reset
thd->lex->sql_command to SQLCOM_REPLACE.

This led to that a statement was detected as a row-type during binlogging,
and was logged as not standalone.

So the corresponding Gtid_log_event, when applied on replica, did not exit
early and created a new PSI transaction. Hence the difference with
non-online ALTER.
This commit is contained in:
Nikita Malyavin
2023-08-07 22:43:40 +04:00
committed by Sergei Golubchik
parent c373e6c3d6
commit a1af525588
5 changed files with 77 additions and 2 deletions

View File

@@ -4,6 +4,29 @@ connection master;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
connection slave;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
# MDEV-31804 Assertion `thd->m_transaction_psi == __null' fails upon
# replicating online ALTER
connection master;
create table t (a char(8)) engine=myisam;
insert into t values ('foo'),('bar');
set debug_sync= 'alter_table_online_progress signal go_dml wait_for go_alter';
set @old_slave_exec_mode= @@global.slave_exec_mode;
set @@global.slave_exec_mode= idempotent;
alter table t force;
connection master1;
set debug_sync= 'now wait_for go_dml';
insert into t (a) values ('qux');
set debug_sync= 'now signal go_alter';
connection master;
connection slave;
connection master;
drop table t;
set global slave_exec_mode= @old_slave_exec_mode;
set debug_sync= reset;
#
# End of 11.2 tests (Single-phase alter)
#
connection slave;
include/stop_slave.inc
set global slave_parallel_threads=3;
set global slave_parallel_mode= optimistic;
@@ -49,6 +72,9 @@ connection master;
drop table t;
connection slave;
connection master;
#
# End of 11.2 tests (Two-phase alter)
#
connection slave;
include/stop_slave.inc
set global binlog_row_image=FULL;

View File

@@ -8,6 +8,46 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state
--connection slave
call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
#
# Single-phase alter
#
--echo # MDEV-31804 Assertion `thd->m_transaction_psi == __null' fails upon
--echo # replicating online ALTER
--connection master
create table t (a char(8)) engine=myisam;
insert into t values ('foo'),('bar');
set debug_sync= 'alter_table_online_progress signal go_dml wait_for go_alter';
set @old_slave_exec_mode= @@global.slave_exec_mode;
set @@global.slave_exec_mode= idempotent;
send alter table t force;
--connection master1
set debug_sync= 'now wait_for go_dml';
insert into t (a) values ('qux');
set debug_sync= 'now signal go_alter';
--connection master
--reap
--sync_slave_with_master
# Cleanup
--connection master
drop table t;
set global slave_exec_mode= @old_slave_exec_mode;
set debug_sync= reset;
--echo #
--echo # End of 11.2 tests (Single-phase alter)
--echo #
#
# Two-phase alter
#
--connection slave
source include/stop_slave.inc;
--let $slave_parallel_threads=`select @@global.slave_parallel_threads`
--let $slave_parallel_mode= `select @@global.slave_parallel_mode`
@@ -75,7 +115,7 @@ drop table t;
--connection master
--echo #
--echo # End of 11.2 tests
--echo # End of 11.2 tests (Two-phase alter)
--echo #
--connection slave