mariadb/mysql-test/suite/galera/t/create.test
Nirbhay Choubey 90f222ea7d MDEV-10235: Deadlock in CREATE TABLE .. AS SELECT .. if result set is empty in Galera
In CTAS, handlers get registered under statement transaction
(st_transactions::stmt), while ha_fake_trx_id(), used by CTAS,
looked under standard transaction (st_transactions::all) for
registered handlers, and thus it failed to grab a fake transaction
ID. As a result, with no valid transaction ID, wsrep commit failed
with an error.

ha_fake_trx_id() now looks for handlers registered under 'stmt'
in case 'all' is empty. Also modified the logic to print warning
only once if none of the registered handlers have fake_trx_id.
2016-06-27 18:21:00 -04:00

89 lines
2 KiB
Text

--source include/galera_cluster.inc
--source include/have_innodb.inc
--echo #
--echo # MDEV-6924 : Server crashed on CREATE TABLE ... SELECT
--echo #
SET @wsrep_forced_binlog_format_saved=@@GLOBAL.wsrep_forced_binlog_format;
SET @@GLOBAL.wsrep_forced_binlog_format=STATEMENT;
# @@log_bin must be OFF
SHOW VARIABLES LIKE '%log%bin%';
USE test;
CREATE TABLE t1(i INT) ENGINE=INNODB;
INSERT INTO t1 VALUES(1);
CREATE TEMPORARY TABLE `t1_temp` AS SELECT * FROM `t1` WHERE i = 1;
SELECT * FROM t1;
SELECT * FROM t1_temp;
# Cleanup
DROP TABLE t1;
SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved;
--echo #
--echo # MDEV-7673: CREATE TABLE SELECT fails on Galera cluster
--echo #
--connection node_1
CREATE TABLE t1 (i INT) ENGINE=INNODB DEFAULT CHARSET=utf8 SELECT 1 as i;
SELECT * FROM t1;
--connection node_2
SELECT * FROM t1;
# Cleanup
DROP TABLE t1;
--echo #
--echo # MDEV-8166 : Adding index on new table from select crashes Galera
--echo # cluster
--echo #
--connection node_1
CREATE TABLE t1(i int(11) NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO t1(i) VALUES (1), (2), (3);
CREATE TABLE t2 (i INT) SELECT i FROM t1;
ALTER TABLE t2 ADD INDEX idx(i);
SELECT * FROM t2;
--connection node_2
SELECT * FROM t2;
SHOW CREATE TABLE t2;
# Cleanup
DROP TABLE t1, t2;
--echo #
--echo # MDEV-9853: WSREP says it cannot get fake InnoDB transaction ID
--echo # followed by segmentation fault
--echo #
CREATE TABLE `t1`(`c1` INT) ENGINE=INNODB;
SET autocommit=0;
CREATE TABLE `t2` (`c1` INT) ENGINE=INNODB SELECT * FROM t1;
COMMIT;
SET autocommit=1;
# Cleanup
DROP TABLE t1, t2;
--echo #
--echo # MDEV-10235: Deadlock in CREATE TABLE ... AS SELECT .. if result set
--echo # is empty in Galera
--echo #
--connection node_1
CREATE TABLE t1(c1 INT) ENGINE=INNODB;
INSERT INTO t1 VALUES(1);
CREATE TABLE t2 AS SELECT * FROM t1 WHERE c1=2;
--connection node_2
SELECT * FROM t1;
SELECT * FROM t2;
# Cleanup
DROP TABLE t1, t2;
--source include/galera_end.inc
--echo # End of tests