2013-03-11 12:07:09 +01:00
--source include/have_innodb.inc
2013-03-26 10:35:34 +01:00
--source include/have_debug.inc
2013-03-11 12:07:09 +01:00
--source include/master-slave.inc
2013-05-22 17:36:48 +02:00
--echo *** Test that we check against incorrect table definition for mysql.gtid_slave_pos ***
2013-03-11 12:07:09 +01:00
--connection master
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
--sync_slave_with_master
--connection slave
--source include/stop_slave.inc
2013-05-22 17:36:48 +02:00
ALTER TABLE mysql.gtid_slave_pos CHANGE seq_no seq_no VARCHAR(20);
2013-03-11 12:07:09 +01:00
START SLAVE;
--connection master
INSERT INTO t1 VALUES (1);
--connection slave
2013-05-22 17:36:48 +02:00
CALL mtr.add_suppression("Slave: Failed to open mysql.gtid_slave_pos");
2013-04-15 10:55:27 +02:00
--let $slave_sql_errno=1942
2013-03-11 12:07:09 +01:00
--source include/wait_for_slave_sql_error.inc
--source include/stop_slave.inc
2013-05-22 17:36:48 +02:00
ALTER TABLE mysql.gtid_slave_pos CHANGE seq_no seq_no BIGINT UNSIGNED NOT NULL;
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (sub_id, domain_id);
2013-03-11 12:07:09 +01:00
START SLAVE;
2013-04-15 10:55:27 +02:00
--let $slave_sql_errno=1942
2013-03-11 12:07:09 +01:00
--source include/wait_for_slave_sql_error.inc
--source include/stop_slave.inc
2013-05-22 17:36:48 +02:00
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
2013-03-11 12:07:09 +01:00
START SLAVE;
2013-04-15 10:55:27 +02:00
--let $slave_sql_errno=1942
2013-03-11 12:07:09 +01:00
--source include/wait_for_slave_sql_error.inc
--source include/stop_slave.inc
2013-05-22 17:36:48 +02:00
ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (sub_id);
2013-03-11 12:07:09 +01:00
START SLAVE;
2013-04-15 10:55:27 +02:00
--let $slave_sql_errno=1942
2013-03-11 12:07:09 +01:00
--source include/wait_for_slave_sql_error.inc
--source include/stop_slave.inc
2013-05-22 17:36:48 +02:00
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (domain_id, sub_id);
2013-03-11 12:07:09 +01:00
--source include/start_slave.inc
--connection master
--sync_slave_with_master
--connection slave
SELECT * FROM t1;
2013-03-18 15:09:36 +01:00
2013-06-07 09:31:11 +02:00
--echo *** Test that setting @@gtid_domain_id or @@gtid_seq_no is not allowed inside a transaction. ***
BEGIN;
INSERT INTO t1 VALUES (100);
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
SET SESSION gtid_domain_id= 100;
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
SET SESSION gtid_seq_no= 100;
SET @old_domain= @@GLOBAL.gtid_domain_id;
SET GLOBAL gtid_domain_id= 100;
SELECT @@SESSION.gtid_domain_id;
SET GLOBAL gtid_domain_id= @old_domain;
INSERT INTO t1 VALUES (101);
SELECT * FROM t1 ORDER BY a;
ROLLBACK;
SELECT * FROM t1 ORDER BY a;
2013-03-18 15:09:36 +01:00
--echo *** Test requesting an explicit GTID position that conflicts with newer GTIDs of our own in the binlog. ***
--connection slave
--source include/stop_slave.inc
--connection master
RESET MASTER;
# This insert will be GTID 0-1-1
INSERT INTO t1 VALUES (2);
# And this will be GTID 0-1-2
INSERT INTO t1 VALUES (4);
--connection slave
SET sql_log_bin = 0;
INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1;
INSERT INTO t1 VALUES (3);
2013-05-22 17:36:48 +02:00
CHANGE MASTER TO master_use_gtid=current_pos;
# Most not change @@GLOBAL.gtid_slave_pos in the middle of a transaction.
BEGIN;
--error ER_CANT_DO_THIS_DURING_AN_TRANSACTION
SET GLOBAL gtid_slave_pos = "100-100-100";
INSERT INTO t1 VALUES (100);
--error ER_CANT_DO_THIS_DURING_AN_TRANSACTION
SET GLOBAL gtid_slave_pos = "100-100-100";
ROLLBACK;
# In gtid non-strict mode, we get warnings for setting @@gtid_slave_pos back
2013-05-28 13:28:31 +02:00
# to earlier than what is in the binlog. In strict mode, we get an error.
SET GLOBAL gtid_strict_mode= 1;
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
SET GLOBAL gtid_slave_pos = "0-1-1";
--error ER_MASTER_GTID_POS_MISSING_DOMAIN
SET GLOBAL gtid_slave_pos = "";
SET GLOBAL gtid_strict_mode= 0;
2013-05-22 17:36:48 +02:00
SET GLOBAL gtid_slave_pos = "0-1-1";
SET GLOBAL gtid_slave_pos = "";
2013-03-18 15:09:36 +01:00
RESET MASTER;
2013-05-22 17:36:48 +02:00
SET GLOBAL gtid_slave_pos = "0-1-1";
2013-03-18 15:09:36 +01:00
START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a;
2013-06-21 11:53:46 +02:00
--echo *** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos ***
# The problem was that record_gtid() deleted too much of the in-memory state,
# leaving the state empty until after commit when we add the newly committed
# GTID. Test this by forcing an error after the delete of the old data but
# before the add of new data.
--source include/stop_slave.inc
--connection master
# This will be GTID 0-1-3
INSERT INTO t1 VALUES (5);
--connection slave
SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
SET GLOBAL debug_dbug="+d,gtid_fail_after_record_gtid";
SET sql_log_bin=0;
CALL mtr.add_suppression('Got error 131 "Command not supported by database" during COMMIT');
SET sql_log_bin=1;
START SLAVE;
--let $slave_sql_errno= 1180
--source include/wait_for_slave_sql_error.inc
# The bug was that @@GLOBAL.gtid_slave_pos was empty here.
SELECT @@GLOBAL.gtid_slave_pos;
SELECT * FROM t1 ORDER BY a;
SET GLOBAL debug_dbug= @old_dbug;
START SLAVE SQL_THREAD;
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a;
2013-03-18 15:09:36 +01:00
--echo *** Test slave requesting a GTID that is not present in the master's binlog ***
--source include/stop_slave.inc
2013-06-21 11:53:46 +02:00
SET GLOBAL gtid_slave_pos = "0-1-4";
2013-03-18 15:09:36 +01:00
START SLAVE;
SET sql_log_bin=0;
CALL mtr.add_suppression("Got fatal error .* from master when reading data from binary log: 'Error: connecting slave requested to start from GTID .*, which is not in the master's binlog'");
SET sql_log_bin=1;
--let $slave_io_errno= 1236
--source include/wait_for_slave_io_error.inc
--let $status_items= Slave_IO_State, Last_IO_Errno, Last_IO_Error, Using_Gtid
--source include/show_slave_status.inc
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
2013-06-21 11:53:46 +02:00
SET GLOBAL gtid_slave_pos = "0-1-3";
2013-03-18 15:09:36 +01:00
START SLAVE;
--source include/wait_for_slave_to_start.inc
--connection master
2013-06-21 11:53:46 +02:00
INSERT INTO t1 VALUES (6);
2013-03-18 15:09:36 +01:00
--connection slave
2013-06-21 11:53:46 +02:00
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1
2013-03-18 15:09:36 +01:00
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a;
2013-03-21 12:16:04 +01:00
--echo *** MDEV-4278: Slave does not detect that master is not GTID-aware ***
--connection slave
--source include/stop_slave.inc
--connection master
SET @old_dbug= @@global.DEBUG_DBUG;
SET GLOBAL debug_dbug="+d,simulate_non_gtid_aware_master";
--connection slave
START SLAVE;
--let $slave_io_errno= 1233
--source include/wait_for_slave_io_error.inc
--connection master
SET GLOBAL debug_dbug= @old_dbug;
2013-06-21 11:53:46 +02:00
INSERT INTO t1 VALUES (7);
2013-03-21 12:16:04 +01:00
--save_master_pos
--connection slave
START SLAVE;
--sync_with_master
SET sql_log_bin=0;
CALL mtr.add_suppression("The slave I/O thread stops because master does not support MariaDB global transaction id");
SET sql_log_bin=1;
2013-03-21 17:33:29 +01:00
--echo *** Test error during record_gtid() (non-xid cases) ***
--connection slave
--source include/stop_slave.inc
--connection master
CREATE TABLE t2 (a INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1);
--save_master_pos
--connection slave
SET @old_dbug= @@global.DEBUG_DBUG;
SET GLOBAL debug_dbug="+d,gtid_inject_record_gtid";
START SLAVE;
2013-04-15 10:55:27 +02:00
--let $slave_sql_errno= 1942
2013-03-21 17:33:29 +01:00
--source include/wait_for_slave_sql_error.inc
SET GLOBAL debug_dbug= @old_dbug;
START SLAVE SQL_THREAD;
--sync_with_master
SELECT * FROM t2;
SET sql_log_bin=0;
CALL mtr.add_suppression("Slave: Could not update replication slave gtid state");
SET sql_log_bin=1;
2013-03-11 12:07:09 +01:00
--connection master
DROP TABLE t1;
2013-03-21 17:33:29 +01:00
DROP TABLE t2;
2013-03-11 12:07:09 +01:00
--source include/rpl_end.inc