Commit e757e024 authored by Sachin Setiya's avatar Sachin Setiya

Galera MTR Tests: Copy over some MTR tests from PXC

Signed-off-by: default avatarSachin Setiya <sachin.setiya@mariadb.com>
parent 912ca4c1
#
# Let's understand the topology.
# * Independent Master with server-id = 1
# * Galera cluster with 2 nodes: node#1 and node#2 with server-id = 2, 3
# node#1 act as slave to Independent Master with server-id = 1
# * Independent Slave with server-id = 4 replicating from galera node#2
#
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld]
log-slave-updates
log-bin=mysqld-bin
binlog-format=row
gtid-mode=on
enforce-gtid-consistency=true
[mysqld.1]
server-id=1
[mysqld.2]
server-id=2
wsrep_provider=@ENV.WSREP_PROVIDER
wsrep_cluster_address='gcomm://'
wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;'
# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
# Required for Galera
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
[mysqld.3]
server-id=3
wsrep_provider=@ENV.WSREP_PROVIDER
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port'
wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;'
# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
# Required for Galera
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
[mysqld.4]
server-id=4
[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
NODE_MYPORT_2= @mysqld.2.port
NODE_MYSOCK_2= @mysqld.2.socket
NODE_MYPORT_3= @mysqld.3.port
NODE_MYSOCK_3= @mysqld.3.socket
NODE_MYPORT_4= @mysqld.4.port
NODE_MYSOCK_4= @mysqld.4.socket
NODE_GALERAPORT_2= @mysqld.2.#galera_port
NODE_GALERAPORT_3= @mysqld.3.#galera_port
NODE_SSTPORT_2= @mysqld.2.#sst_port
NODE_SSTPORT_3= @mysqld.3.#sst_port
#
# This .cnf file creates a setup with a 2-node Galera cluster and one stand-alone MySQL server, to be used as a slave
#
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld]
default-storage-engine=InnoDB
[mysqld.1]
server-id=1
binlog-format=row
log-bin=mysqld-bin
log_slave_updates
gtid-mode=on
enforce-gtid-consistency=true
event-scheduler=1
wsrep_provider=@ENV.WSREP_PROVIDER
wsrep_cluster_address='gcomm://'
wsrep_provider_options='base_port=@mysqld.1.#galera_port'
# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port
# Required for Galera
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
[mysqld.2]
server-id=2
binlog-format=row
log-bin=mysqld-bin
log_slave_updates
gtid-mode=on
enforce-gtid-consistency=true
event-scheduler=1
wsrep_provider=@ENV.WSREP_PROVIDER
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
wsrep_provider_options='base_port=@mysqld.2.#galera_port'
# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
# Required for Galera
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
[mysqld.3]
server-id=3
replicate-ignore-db=test
replicate-wild-ignore-table=test.%
log-bin=mysqld-bin
log_slave_updates
gtid-mode=on
enforce-gtid-consistency=true
event-scheduler=1
[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
NODE_MYPORT_2= @mysqld.2.port
NODE_MYSOCK_2= @mysqld.2.socket
NODE_MYPORT_3= @mysqld.3.port
NODE_MYSOCK_3= @mysqld.3.socket
NODE_GALERAPORT_1= @mysqld.1.#galera_port
NODE_GALERAPORT_2= @mysqld.2.#galera_port
NODE_SSTPORT_1= @mysqld.1.#sst_port
NODE_SSTPORT_2= @mysqld.2.#sst_port
SAVEPOINT in a stored function should be forbidden
CREATE FUNCTION f1 () RETURNS INT BEGIN
SAVEPOINT s;
RETURN 1;
END|
SELECT f1();
f1()
1
DROP FUNCTION f1;
ROLLBACK TO SAVEPOINT in a stored function should be forbidden
CREATE FUNCTION f2 () RETURNS INT BEGIN
ROLLBACK TO SAVEPOINT s;
RETURN 1;
END|
BEGIN;
SAVEPOINT s;
SELECT f2();
ERROR 42000: SAVEPOINT s does not exist
COMMIT;
DROP FUNCTION f2;
BEGIN;
SAVEPOINT S;
ROLLBACK TO SAVEPOINT S;
COMMIT;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 values (110), (111), (112), (113), (114);
Direct SAVEPOINT in a trigger should be forbidden
CREATE TRIGGER i1_t1 BEFORE INSERT ON t1 FOR EACH ROW SAVEPOINT s;
INSERT INTO t1 VALUES (1);
DROP TRIGGER i1_t1;
CREATE TRIGGER i2_t1 AFTER INSERT ON t1 FOR EACH ROW SAVEPOINT s;
INSERT INTO t1 VALUES (2);
DROP TRIGGER i2_t1;
INSERT INTO t1 VALUES (3);
CREATE TRIGGER u1_t1 BEFORE UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
UPDATE t1 SET a=4 WHERE a=3;
DROP TRIGGER u1_t1;
CREATE TRIGGER u2_t1 AFTER UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
UPDATE t1 SET a=4 WHERE a=3;
DROP TRIGGER u2_t1;
CREATE TRIGGER d1_t1 BEFORE DELETE ON t1 FOR EACH ROW SAVEPOINT s;
DELETE FROM t1;
DROP TRIGGER d1_t1;
CREATE TRIGGER d1_t1 AFTER DELETE ON t1 FOR EACH ROW SAVEPOINT s;
DELETE FROM t1;
DROP TRIGGER d1_t1;
SAVEPOINT in a compound statement in a trigger should be forbidden
CREATE TRIGGER i3_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
SAVEPOINT s;
END|
INSERT INTO t1 VALUES (5);
DROP TRIGGER i3_t1;
SAVEPOINT in a PS call in a trigger should be forbidden
CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
PREPARE set_savepoint FROM "SAVEPOINT s";
EXECUTE set_savepoint;
DEALLOCATE PREPARE set_savepoint;
END|
ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
SAVEPOINT in SP called from a trigger should be forbidden
CREATE PROCEDURE p1() BEGIN
SAVEPOINT s;
END|
CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
INSERT INTO t1 VALUES (6);
DROP TRIGGER i5_t1;
SAVEPOINT in a SP called from a PS called from a trigger be forbidden
PREPARE call_p1 FROM "CALL p1";
CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW EXECUTE call_p1;
ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
SAVEPOINT in a function called from a trigger should be forbidden
CREATE FUNCTION f1 () RETURNS INT BEGIN
SAVEPOINT s;
RETURN 1;
END|
CREATE TRIGGER i7_t1 BEFORE INSERT ON t1 FOR EACH ROW SET @foo = f1();
INSERT INTO t1 VALUES (7);
DROP TRIGGER i7_t1;
SAVEPOINT in a SP called from a SP called from a trigger should be forbidden
CREATE PROCEDURE p2() BEGIN
CALL p1();
END|
CREATE TRIGGER i8_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p2;
INSERT INTO t1 VALUES (8);
DROP TRIGGER i8_t1;
SAVEPOINT in a SP called from a trigger called from a SP should be forbidden
CREATE TRIGGER i9_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
CREATE PROCEDURE p3() BEGIN
INSERT INTO t1 VALUES (9);
END|
CALL p3();
DROP TRIGGER i9_t1;
ROLLBACK TO SAVEPOINT in trigger as a trivial statement should be forbidden
CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW ROLLBACK TO SAVEPOINT s;
BEGIN;
SAVEPOINT s;
INSERT INTO t1 VALUES (5);
ERROR 42000: SAVEPOINT s does not exist
COMMIT;
DROP TRIGGER i4_t1;
ROLLBACK TO SAVEPOINT in a trigger in a SP call should be forbidden
CREATE PROCEDURE p4() BEGIN
ROLLBACK TO SAVEPOINT s;
END|
CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p4;
BEGIN;
SAVEPOINT s;
INSERT INTO t1 VALUES (6);
ERROR 42000: SAVEPOINT s does not exist
COMMIT;
DROP TRIGGER i5_t1;
SAVEPOINT in a SP next to a trigger should work
CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = NEW.a + 1;
CREATE PROCEDURE p5() BEGIN
SAVEPOINT s;
INSERT INTO t1 VALUES (10);
ROLLBACK TO SAVEPOINT s;
END|
BEGIN;
CALL p5();
COMMIT;
DROP TRIGGER i6_t1;
create trigger t1 before insert on t1 for each row
begin
insert into t2 values (NULL);
end|
INSERT INTO t1 VALUES (201), (202), (203);
SELECT * FROM t1;
a
5
6
7
8
9
201
202
203
SELECT COUNT(*) FROM t2;
COUNT(*)
3
SELECT * FROM t1;
a
5
6
7
8
9
201
202
203
SELECT COUNT(*) FROM t2;
COUNT(*)
3
DEALLOCATE PREPARE call_p1;
DROP TABLE t1, t2;
DROP PROCEDURE p1;
DROP PROCEDURE p2;
DROP PROCEDURE p3;
DROP PROCEDURE p4;
DROP PROCEDURE p5;
DROP FUNCTION f1;
DROP TABLE IF EXISTS t1, t2;
DROP TABLE IF EXISTS x1, x2;
CREATE TABLE t1 (f1 INTEGER);
CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER);
SET GLOBAL wsrep_replicate_myisam = TRUE;
CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM;
CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4;
INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
# ANALYZE test
ANALYZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
# OPTIMIZE test
OPTIMIZE TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
test.t2 optimize note Table does not support optimize, doing recreate + analyze instead
test.t2 optimize status OK
# REPAIR test
REPAIR TABLE x1, x2;
Table Op Msg_type Msg_text
test.x1 repair status OK
test.x2 repair status OK
SELECT COUNT(*) = 10 FROM t1;
COUNT(*) = 10
1
SELECT COUNT(*) = 10 FROM x1;
COUNT(*) = 10
1
SELECT COUNT(*) = 10000 FROM t2;
COUNT(*) = 10000
1
SELECT COUNT(*) = 10 FROM x2;
COUNT(*) = 10
1
DROP TABLE t1, t2;
DROP TABLE x1, x2;
SET GLOBAL wsrep_replicate_myisam = FALSE;
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
CREATE TABLE t2 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
SET GLOBAL wsrep_desync = 1;
show status like 'wsrep_desync_count';
Variable_name Value
wsrep_desync_count 1
SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter1 WAIT_FOR alter2';
INSERT INTO t1 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
SET GLOBAL wsrep_desync = 1;
Warnings:
Warning 1231 'wsrep_desync' is already ON.
show status like 'wsrep_desync_count';
Variable_name Value
wsrep_desync_count 1
SET DEBUG_SYNC='now WAIT_FOR alter1';
SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter2';
INSERT INTO t2 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
SET DEBUG_SYNC='RESET';
SET GLOBAL wsrep_desync = 0;
show status like 'wsrep_desync_count';
Variable_name Value
wsrep_desync_count 0
SET GLOBAL wsrep_desync = 0;
Warnings:
Warning 1231 'wsrep_desync' is already OFF.
show status like 'wsrep_desync_count';
Variable_name Value
wsrep_desync_count 0
show status like 'wsrep_desync_count';
Variable_name Value
wsrep_desync_count 0
SET GLOBAL wsrep_desync = 0;
Warnings:
Warning 1231 'wsrep_desync' is already OFF.
SELECT COUNT(*) FROM t1;
COUNT(*)
1000
SELECT COUNT(*) FROM t2;
COUNT(*)
1000
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE ten;
CALL mtr.add_suppression("Aborting");
CALL mtr.add_suppression("unknown option '--galera-unknown-option'");
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');
SELECT * FROM t1;
f1 f2
1 a
2 a
3 a
Shutting down server ...
UPDATE t1 SET f2 = 'b' WHERE f1 > 1;
UPDATE t1 SET f2 = 'c' WHERE f1 > 2;
SELECT * FROM t1;
f1 f2
1 a
2 b
3 c
Starting server ...
Starting server ...
SELECT * FROM t1;
f1 f2
1 a
2 b
3 c
Shutting down server ...
UPDATE t1 SET f2 = 'd' WHERE f1 > 1;
UPDATE t1 SET f2 = 'd' WHERE f1 > 2;
SELECT * FROM t1;
f1 f2
1 a
2 d
3 d
Starting server ...
Starting server ...
SELECT * FROM t1;
f1 f2
1 a
2 d
3 d
DROP TABLE t1;
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY AUTO_INCREMENT,
parent_id INT
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1);
INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE;;
UPDATE parent SET id = 2 WHERE id = 1;;
SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
COUNT(*) = 10000
1
SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
COUNT(*) = 10000
1
DROP TABLE child;
DROP TABLE parent;
DROP TABLE ten;
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;;
CREATE INDEX i1 ON t1 (f2);;
ALTER TABLE t1 ADD COLUMN f3 INTEGER;;
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
1
SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
COUNT(*) = 3
1
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1';
COUNT(*) = 2
1
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
1
SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
COUNT(*) = 3
1
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1';
COUNT(*) = 2
1
DROP TABLE t1;
DROP TABLE ten;
CREATE DATABASE database1;
USE database1;
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;;
USE database1;
INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;;
DROP DATABASE database1;;
ERROR 42S02: Table 'database1.t1' doesn't exist
ERROR 42S02: Table 'database1.t2' doesn't exist
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
COUNT(*) = 0
1
USE database1;
ERROR 42000: Unknown database 'database1'
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
COUNT(*) = 0
1
USE database1;
ERROR 42000: Unknown database 'database1'
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
TRUNCATE TABLE t1;;
SELECT COUNT(*) = 1000000 FROM t1;
COUNT(*) = 1000000
1
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
TRUNCATE TABLE t1;;
SELECT COUNT(*) = 1000000 FROM t1;
COUNT(*) = 1000000
1
DROP TABLE t1;
DROP TABLE ten;
call mtr.add_suppression("WSREP\: Unknown parameter 'gmcasts\.segment'");
call mtr.add_suppression("WSREP\: Set options returned 7");
SET GLOBAL wsrep_provider_options="gmcasts.segment=1";
ERROR HY000: Incorrect arguments to SET
Unhandled exceptions: 0
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
FLUSH TABLES t1 FOR EXPORT;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
UNLOCK TABLES;
### t1 should have column f2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`f2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from t1;
id f2
1 NULL
2 3
DROP TABLE t1;
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
FLUSH TABLE WITH READ LOCK;
### This shouldn't block.
FLUSH TABLES t1 FOR EXPORT;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
UNLOCK TABLES;
### t1 should have column f2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`f2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (2,3);
SELECT * from t1;
id f2
1 NULL
2 3
DROP TABLE t1;
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
SET session wsrep_sync_wait=0;
SET session wsrep_causal_reads=OFF;
FLUSH TABLE WITH READ LOCK;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
SET session wsrep_sync_wait=0;
SET session wsrep_causal_reads=OFF;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
FLUSH TABLES t1 WITH READ LOCK;;
UNLOCK TABLES;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
UNLOCK TABLES;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`f2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from t1;
id f2
1 NULL
2 3
DROP TABLE t1;
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
FLUSH TABLES t1 WITH READ LOCK;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
UNLOCK TABLES;
### t1 should have column f2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`f2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from t1;
id f2
1 NULL
2 3
DROP TABLE t1;
set GLOBAL wsrep_slave_threads=26;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 (f1) SELECT * from t1 as x1;
set GLOBAL wsrep_slave_threads=16;
SET GLOBAL wsrep_provider='none';
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
set GLOBAL wsrep_slave_threads=5;
SELECT COUNT(*) = 5 FROM t1;
COUNT(*) = 5
1
set GLOBAL wsrep_slave_threads=12;
SELECT COUNT(*) = 4 FROM t1;
COUNT(*) = 4
1
INSERT INTO t1 VALUES (100), (101), (102);
set GLOBAL wsrep_slave_threads=5;
INSERT INTO t1 (f1) SELECT * from t1 as x1;
show global variables like 'wsrep_slave_threads';
Variable_name Value
wsrep_slave_threads 5
SET GLOBAL wsrep_slave_threads = 1;
SELECT COUNT(*) FROM t1;
COUNT(*)
16
SELECT COUNT(*) FROM t1;
COUNT(*)
15
show global variables like 'wsrep_slave_threads';
Variable_name Value
wsrep_slave_threads 12
SET GLOBAL wsrep_slave_threads = 1;
DROP TABLE t1;
# Disable SAVEPOINT and ROLLBACK TO SAVEPOINT in SP, SF, TR.
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
--echo SAVEPOINT in a stored function should be forbidden
--delimiter |
CREATE FUNCTION f1 () RETURNS INT BEGIN
SAVEPOINT s;
RETURN 1;
END|
--delimiter ;
SELECT f1();
DROP FUNCTION f1;
--echo ROLLBACK TO SAVEPOINT in a stored function should be forbidden
--delimiter |
CREATE FUNCTION f2 () RETURNS INT BEGIN
ROLLBACK TO SAVEPOINT s;
RETURN 1;
END|
--delimiter ;
BEGIN;
SAVEPOINT s;
--error ER_SP_DOES_NOT_EXIST
SELECT f2();
COMMIT;
DROP FUNCTION f2;
BEGIN;
SAVEPOINT S;
ROLLBACK TO SAVEPOINT S;
COMMIT;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 values (110), (111), (112), (113), (114);
--echo Direct SAVEPOINT in a trigger should be forbidden
--connection node_2
CREATE TRIGGER i1_t1 BEFORE INSERT ON t1 FOR EACH ROW SAVEPOINT s;
--connection node_1
INSERT INTO t1 VALUES (1);
DROP TRIGGER i1_t1;
CREATE TRIGGER i2_t1 AFTER INSERT ON t1 FOR EACH ROW SAVEPOINT s;
INSERT INTO t1 VALUES (2);
DROP TRIGGER i2_t1;
INSERT INTO t1 VALUES (3);
CREATE TRIGGER u1_t1 BEFORE UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
UPDATE t1 SET a=4 WHERE a=3;
DROP TRIGGER u1_t1;
CREATE TRIGGER u2_t1 AFTER UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
UPDATE t1 SET a=4 WHERE a=3;
DROP TRIGGER u2_t1;
CREATE TRIGGER d1_t1 BEFORE DELETE ON t1 FOR EACH ROW SAVEPOINT s;
DELETE FROM t1;
DROP TRIGGER d1_t1;
CREATE TRIGGER d1_t1 AFTER DELETE ON t1 FOR EACH ROW SAVEPOINT s;
DELETE FROM t1;
DROP TRIGGER d1_t1;
--echo SAVEPOINT in a compound statement in a trigger should be forbidden
--delimiter |
CREATE TRIGGER i3_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
SAVEPOINT s;
END|
--delimiter ;
INSERT INTO t1 VALUES (5);
DROP TRIGGER i3_t1;
--echo SAVEPOINT in a PS call in a trigger should be forbidden
# echo handled by SAVEPOINT forbidden in PS
--delimiter |
--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
PREPARE set_savepoint FROM "SAVEPOINT s";
EXECUTE set_savepoint;
DEALLOCATE PREPARE set_savepoint;
END|
--delimiter ;
--connection node_2
--echo SAVEPOINT in SP called from a trigger should be forbidden
--delimiter |
CREATE PROCEDURE p1() BEGIN
SAVEPOINT s;
END|
--delimiter ;
--connection node_1
CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
INSERT INTO t1 VALUES (6);
DROP TRIGGER i5_t1;
--echo SAVEPOINT in a SP called from a PS called from a trigger be forbidden
# echo handled by SAVEPOINT forbidden in PS
PREPARE call_p1 FROM "CALL p1";
--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW EXECUTE call_p1;
--echo SAVEPOINT in a function called from a trigger should be forbidden
--delimiter |
CREATE FUNCTION f1 () RETURNS INT BEGIN
SAVEPOINT s;
RETURN 1;
END|
--delimiter ;
CREATE TRIGGER i7_t1 BEFORE INSERT ON t1 FOR EACH ROW SET @foo = f1();
INSERT INTO t1 VALUES (7);
DROP TRIGGER i7_t1;
--echo SAVEPOINT in a SP called from a SP called from a trigger should be forbidden
--delimiter |
CREATE PROCEDURE p2() BEGIN
CALL p1();
END|
--delimiter ;
CREATE TRIGGER i8_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p2;
INSERT INTO t1 VALUES (8);
DROP TRIGGER i8_t1;
--echo SAVEPOINT in a SP called from a trigger called from a SP should be forbidden
CREATE TRIGGER i9_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
--delimiter |
CREATE PROCEDURE p3() BEGIN
INSERT INTO t1 VALUES (9);
END|
--delimiter ;
CALL p3();
DROP TRIGGER i9_t1;
--echo ROLLBACK TO SAVEPOINT in trigger as a trivial statement should be forbidden
# Trigger activation creates a new savepoint level, making the earlier levels
# inaccessible. Thus forbidding SAVEPOINT should be enough as then there is
# no valid savepoint to pass to ROLLBACK TO SAVEPOINT, but we forbid it once
# more just in case.
CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW ROLLBACK TO SAVEPOINT s;
BEGIN;
SAVEPOINT s;
--error ER_SP_DOES_NOT_EXIST
INSERT INTO t1 VALUES (5);
COMMIT;
DROP TRIGGER i4_t1;
--echo ROLLBACK TO SAVEPOINT in a trigger in a SP call should be forbidden
--delimiter |
CREATE PROCEDURE p4() BEGIN
ROLLBACK TO SAVEPOINT s;
END|
--delimiter ;
CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p4;
BEGIN;
SAVEPOINT s;
--error ER_SP_DOES_NOT_EXIST
INSERT INTO t1 VALUES (6);
COMMIT;
DROP TRIGGER i5_t1;
--echo SAVEPOINT in a SP next to a trigger should work
CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = NEW.a + 1;
--delimiter |
CREATE PROCEDURE p5() BEGIN
SAVEPOINT s;
INSERT INTO t1 VALUES (10);
ROLLBACK TO SAVEPOINT s;
END|
--delimiter ;
BEGIN;
CALL p5();
COMMIT;
DROP TRIGGER i6_t1;
--connection node_2
delimiter |;
create trigger t1 before insert on t1 for each row
begin
insert into t2 values (NULL);
end|
delimiter ;|
--connection node_1
INSERT INTO t1 VALUES (201), (202), (203);
--connection node_1
SELECT * FROM t1;
SELECT COUNT(*) FROM t2;
--connection node_2
SELECT * FROM t1;
SELECT COUNT(*) FROM t2;
--connection node_1
DEALLOCATE PREPARE call_p1;
--connection node_2
DROP TABLE t1, t2;
DROP PROCEDURE p1;
DROP PROCEDURE p2;
DROP PROCEDURE p3;
DROP PROCEDURE p4;
DROP PROCEDURE p5;
DROP FUNCTION f1;
#
# Test that various admin commands from sql_admin.cc
# Currently, REPAIR, OPTIMIZE and ANALYZE are tested.
# Jira: PXC-390
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP TABLE IF EXISTS x1, x2;
--enable_warnings
--connection node_1
CREATE TABLE t1 (f1 INTEGER);
CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER);
SET GLOBAL wsrep_replicate_myisam = TRUE;
CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM;
CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4;
INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
# Wait until all the data from t2 has been replicated
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 10 FROM x1;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10 FROM x2;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10 FROM t1;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t2;
--source include/wait_condition.inc
--echo # ANALYZE test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
ANALYZE TABLE t1, t2;
--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc
--echo # OPTIMIZE test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
OPTIMIZE TABLE t1, t2;
--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc
--echo # REPAIR test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
REPAIR TABLE x1, x2;
--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc
--connection node_2
SELECT COUNT(*) = 10 FROM t1;
SELECT COUNT(*) = 10 FROM x1;
SELECT COUNT(*) = 10000 FROM t2;
SELECT COUNT(*) = 10 FROM x2;
--connection node_1
DROP TABLE t1, t2;
DROP TABLE x1, x2;
SET GLOBAL wsrep_replicate_myisam = FALSE;
#
# Test for overlapped transactions under manual desync.
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/have_debug_sync.inc
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
CREATE TABLE t2 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
SET GLOBAL wsrep_desync = 1;
show status like 'wsrep_desync_count';
SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter1 WAIT_FOR alter2';
send INSERT INTO t1 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
--connection node_1a
SET GLOBAL wsrep_desync = 1;
show status like 'wsrep_desync_count';
SET DEBUG_SYNC='now WAIT_FOR alter1';
SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter2';
send INSERT INTO t2 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
--connection node_1
reap;
--connection node_1a
reap;
--connection node_1
SET DEBUG_SYNC='RESET';
SET GLOBAL wsrep_desync = 0;
show status like 'wsrep_desync_count';
SET GLOBAL wsrep_desync = 0;
show status like 'wsrep_desync_count';
--disable_query_log
call mtr.add_suppression("Trying to make wsrep_desync = OFF on the node that is already synchronized.");
--enable_query_log
show status like 'wsrep_desync_count';
SET GLOBAL wsrep_desync = 0;
SELECT COUNT(*) FROM t1;
SELECT COUNT(*) FROM t2;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE ten;
--query_cache_type=1 --query_cache_size=1000000 --userstat=1 --wsrep_replicate_myisam=true
--query_cache_type=1 --query_cache_size=1000000
--source include/galera_cluster.inc
--source include/have_innodb.inc
# Suppress expected warnings:
CALL mtr.add_suppression("Aborting");
CALL mtr.add_suppression("unknown option '--galera-unknown-option'");
#
# We should count the number of "Assertion failed" warnings
# in the log file before and after testing. To do this we need
# to save original log file before testing:
#
--let TEST_LOG=$MYSQLTEST_VARDIR/log/mysqld.2.err
--perl
use strict;
my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
my $test_log_copy=$test_log . '.copy';
if (-e $test_log_copy) {
unlink $test_log_copy;
}
EOF
--copy_file $TEST_LOG $TEST_LOG.copy
--connection node_2
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');
SELECT * FROM t1;
# Initiate normal shutdown on the node 2 and
# waiting until shutdown has been completed:
--echo Shutting down server ...
--source include/shutdown_mysqld.inc
--connection node_1
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
# Some updates on node 1:
UPDATE t1 SET f2 = 'b' WHERE f1 > 1;
UPDATE t1 SET f2 = 'c' WHERE f1 > 2;
SELECT * FROM t1;
# Remove the "grastate.dat" file (to initiate new SST)
# and restart node 2 with unknown option:
--connection node_2
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--let $start_mysqld_params=--galera-unknown-option
--echo Starting server ...
--exec echo "try:$start_mysqld_params" > $_expect_file_name
# Sleep to ensure that server exited...
--sleep 30
# Restart node 2 without unknown option:
--let $start_mysqld_params=
--echo Starting server ...
--source include/start_mysqld.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
# Sanity check (node 2 is running now and can perform SQL operators):
SELECT * FROM t1;
# Initiate normal shutdown on the node 2 and
# waiting until shutdown has been completed:
--echo Shutting down server ...
--source include/shutdown_mysqld.inc
--connection node_1
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
# Some updates on node 1 - to initiate IST next time:
UPDATE t1 SET f2 = 'd' WHERE f1 > 1;
UPDATE t1 SET f2 = 'd' WHERE f1 > 2;
SELECT * FROM t1;
# Restart node 2 with unknown option:
--connection node_2
--let $start_mysqld_params=--galera-unknown-option
--echo Starting server ...
--exec echo "try:$start_mysqld_params" > $_expect_file_name
# Sleep to ensure that server exited...
--sleep 30
# Restart node 2 without unknown option:
--let $start_mysqld_params=
--echo Starting server ...
--source include/start_mysqld.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
# Sanity check (node 2 is running now and can perform SQL operators):
SELECT * FROM t1;
--connection node_1
DROP TABLE t1;
#
# We should count the number of "Assertion failed" warnings
# in the log file during test phase - to print the error message
# if quantity of such warnings in log file increased at the end
# of the test:
#
--perl
use strict;
my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
my $test_log_copy=$test_log . '.copy';
open(FILE, $test_log_copy) or die("Unable to open $test_log_copy: $!\n");
my $initial=grep(/Assertion * failed/gi,<FILE>);
close(FILE);
open(FILE, $test_log) or die("Unable to open $test_log: $!\n");
my $count_warnings=grep(/Assertion * failed/gi,<FILE>);
close(FILE);
if ($count_warnings != $initial) {
my $diff=$count_warnings-$initial;
print "Assertion failed $diff times.\n";
}
EOF
--remove_file $TEST_LOG.copy
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# This test creates a new FK constraint while an UPDATE is running
#
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY AUTO_INCREMENT,
parent_id INT
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1);
INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
--connection node_1
--sleep 1
--send ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE;
--connection node_2
--sleep 1
--send UPDATE parent SET id = 2 WHERE id = 1;
--connection node_1
--reap
--connection node_2
--reap
--connection node_2
SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
--connection node_1
SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
DROP TABLE child;
DROP TABLE parent;
DROP TABLE ten;
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# In this test, we run concurrent INSERT against a table against which we have issued concurrent DDL statements that are fully online,
# that is, DDL statements that allow for the DML to proceed non-blocking while the DDL is in progress
#
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_1
--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1a
--send CREATE INDEX i1 ON t1 (f2);
--let $galera_connection_name = node_1b
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1b
--send ALTER TABLE t1 ADD COLUMN f3 INTEGER;
--connection node_1
--reap
--connection node_1a
--reap
--connection node_1b
--reap
--connection node_2
SELECT COUNT(*) = 200000 FROM t1;
SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1';
--connection node_1
SELECT COUNT(*) = 200000 FROM t1;
SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1';
DROP TABLE t1;
DROP TABLE ten;
#
# Test the operation of DDLs that affect multiple database objects
#
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1
CREATE DATABASE database1;
USE database1;
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
# Insert 1M rows
--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_1a
USE database1;
--send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_2
--sleep 1
--send DROP DATABASE database1;
--connection node_1
--sleep 30
--error ER_NO_SUCH_TABLE
--reap
--connection node_1a
--error ER_NO_SUCH_TABLE
--reap
--connection node_2
--reap
--connection node_1
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
--error ER_BAD_DB_ERROR
USE database1;
--connection node_2
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
--error ER_BAD_DB_ERROR
USE database1;
#
# Test the operation of TRUNCATE with concurrent DML. Even in the face of a concurrent INSERT,
# the TRUNCATE will complete first and be recorded in the history before the INSERT.
#
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# INSERT and TRUNCATE on different nodes
#
--connection node_1
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
# Insert 100K rows
--connection node_2
--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
--connection node_1
--sleep 1
--send TRUNCATE TABLE t1;
--connection node_1
--reap
--connection node_2
--reap
--connection node_2
SELECT COUNT(*) = 1000000 FROM t1;
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1;
--source include/wait_condition.inc
DROP TABLE t1;
#
# INSERT AND TRUNCATE on same node
#
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
# Insert 100K rows
--connection node_1
--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
--connection node_1a
--sleep 1
--send TRUNCATE TABLE t1;
--connection node_1
--reap
--connection node_1a
--reap
--connection node_1
SELECT COUNT(*) = 1000000 FROM t1;
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1;
--source include/wait_condition.inc
DROP TABLE t1;
DROP TABLE ten;
#
# PXC-318: Typo in wsrep_provider_options causes an unhandled exception
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let LOGF=$MYSQLTEST_VARDIR/log/mysqld.1.err
--disable_info
call mtr.add_suppression("WSREP\: Unknown parameter 'gmcasts\.segment'");
call mtr.add_suppression("WSREP\: Set options returned 7");
--error ER_WRONG_ARGUMENTS
SET GLOBAL wsrep_provider_options="gmcasts.segment=1";
# Search for unhandled exception message.
perl;
use strict;
my $logf= $ENV{'LOGF'} or die "LOGF not set";
open(FILE, "$logf") or die("Unable to open $logf: $!\n");
my $count_warnings=grep(/terminate called after throwing an instance of /gi,<FILE>);
print "Unhandled exceptions: $count_warnings\n";
close(FILE);
EOF
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_2
FLUSH TABLES t1 FOR EXPORT;
--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
--connection node_2
UNLOCK TABLES;
--echo ### t1 should have column f2
SHOW CREATE TABLE t1;
SELECT * from t1;
--connection node_1
DROP TABLE t1;
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_2
FLUSH TABLE WITH READ LOCK;
--echo ### This shouldn't block.
FLUSH TABLES t1 FOR EXPORT;
--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
--connection node_2
UNLOCK TABLES;
--echo ### t1 should have column f2
SHOW CREATE TABLE t1;
--connection node_1
INSERT INTO t1 VALUES (2,3);
--connection node_2
SELECT * from t1;
--connection node_1
DROP TABLE t1;
#
# Test Flush tables with read lock along with
# flush tables <table> with read lock for compatibility.
# Also, making sure all DDL and DMLs are propagated
# after provider is unpaused
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $galera_connection_name = node_2a
--let $galera_server_number = 2
--source include/galera_connect.inc
--connection node_1
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_2
SET session wsrep_sync_wait=0;
SET session wsrep_causal_reads=OFF;
FLUSH TABLE WITH READ LOCK;
--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
--connection node_2a
SET session wsrep_sync_wait=0;
SET session wsrep_causal_reads=OFF;
SHOW CREATE TABLE t1;
--sleep 1
--send FLUSH TABLES t1 WITH READ LOCK;
--connection node_2
# let the flush table wait in pause state before we unlock
# table otherwise there is window where-in flush table is
# yet to wait in pause and unlock allows alter table to proceed.
# this is because send in asynchronous.
--sleep 3
# this will release existing lock but will not resume
# the cluster as there is new FTRL that is still pausing it.
UNLOCK TABLES;
SHOW CREATE TABLE t1;
--connection node_2a
--reap
UNLOCK TABLES;
--sleep 1
SHOW CREATE TABLE t1;
SELECT * from t1;
--connection node_1
DROP TABLE t1;
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_2
FLUSH TABLES t1 WITH READ LOCK;
--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
--sleep 2
--connection node_2
UNLOCK TABLES;
--echo ### t1 should have column f2
SHOW CREATE TABLE t1;
SELECT * from t1;
--connection node_1
DROP TABLE t1;
#
# PXC-421: Test deadlock involving updates of
# wsrep_provider, wsrep_cluster_address and wsrep_slave_threads.
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
--let $wsrep_slave_1 = `SELECT @@wsrep_slave_threads`
set GLOBAL wsrep_slave_threads=26;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 (f1) SELECT * from t1 as x1;
--connection node_2
--let $wsrep_slave_2 = `SELECT @@wsrep_slave_threads`
set GLOBAL wsrep_slave_threads=16;
--let $wsrep_provider_orig = `SELECT @@wsrep_provider`
--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address`
SET GLOBAL wsrep_provider='none';
INSERT INTO t1 VALUES (2);
--connection node_1
INSERT INTO t1 VALUES (3);
--connection node_2
--disable_query_log
--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig';
--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig';
--enable_query_log
--source include/wait_until_connected_again.inc
--source include/galera_wait_ready.inc
INSERT INTO t1 VALUES (4);
set GLOBAL wsrep_slave_threads=5;
# Node #2 has all the inserts
SELECT COUNT(*) = 5 FROM t1;
--connection node_1
set GLOBAL wsrep_slave_threads=12;
# Node #1 is missing the insert made while Node #2 was not replicated
SELECT COUNT(*) = 4 FROM t1;
INSERT INTO t1 VALUES (100), (101), (102);
--connection node_2
set GLOBAL wsrep_slave_threads=5;
INSERT INTO t1 (f1) SELECT * from t1 as x1;
show global variables like 'wsrep_slave_threads';
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_2
SELECT COUNT(*) FROM t1;
--connection node_1
SELECT COUNT(*) FROM t1;
show global variables like 'wsrep_slave_threads';
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_1
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment