mariadb/mysql-test/suite/rpl/t/global_temporary_table.test
Nikita Malyavin 4519ff4692 MDEV-37718 Assertion '!thd->rgi_slave' failed on GTT DML
Assertion '!thd->rgi_slave' failed in open_global_temporary_table on
CREATE/ANALYZE GTT, also a SIGSEGV in the release build.

This is a result of a fact that some operations led to opening a child
table on slave. The bug can be split in two parts:

1. SELECT part of CREATE...SELECT is replicated. It was binlogged,
despite table_creation_was_logged=0 explicitly set. To avoid, fall to
the row logging path of create_select, i.e. log SHOW CREATE output, but
don't actually log rows.
The relevant changes are in sql_insert.cc

2. Admin commands like ANALYZE TABLE still create a child table on open,
but are binlogged. Binlogging them would be otherwise harmless, but
better to avoid it, until the commands are fully supported and make
sense.
For now, avoid binlogging them with lex->no_write_to_binlog=false.
2025-11-26 19:57:46 +01:00

56 lines
1.3 KiB
Text

-- source include/have_binlog_format_statement.inc
-- source include/master-slave.inc
connection default;
source main/global_temporary_table.test;
sync_slave_with_master;
connection master;
#Safety
set @old_timeout= @@global.lock_wait_timeout;
set lock_wait_timeout= 5;
set global lock_wait_timeout= 5;
create table t(x int, txt text);
create global temporary table gtt(x int) on commit preserve rows;
insert t values (1, 'one'), (2,'two'), (3, 'three'), (4, 'four');
insert gtt values (2),(3),(5);
--connect (con1,localhost,root,,)
insert gtt values (4),(6);
--connection master
update t, gtt set t.txt= CONCAT(t.txt, ' tables') where t.x = gtt.x;
--connection con1
update t, gtt set t.txt= CONCAT(t.txt, ' databases') where t.x = gtt.x;
truncate gtt;
--connection master
select * from t;
sync_slave_with_master;
select * from t;
connection master;
--connection master
truncate gtt;
drop table t;
drop table gtt;
set global lock_wait_timeout= @old_timeout;
--echo # MDEV-38125 Assertion !thd->rgi_slave failed on INSERT under LOCK TABLES
create table t(x int);
create global temporary table src(x int) on commit preserve rows;
insert src values(1);
lock tables t write, src write;
set binlog_format=row;
insert t values(1);
unlock tables;
truncate src;
set binlog_format=statement;
drop table t;
drop table src;
--disconnect con1
--source include/rpl_end.inc