Commit b0389850 authored by unknown's avatar unknown

MDEV-26: Global transaction ID.

Test crashing the master, check that it recovers the binlog state.

Fix one bug introduced by previous commit (crash-recoved binlog state was
overwritten by loading stale binlog state file).

Fix Windows build error.
parent 0fdbdde4
include/rpl_init.inc [topology=1->2]
*** Test crashing master, causing slave IO thread to reconnect while SQL thread is running ***
SET sql_log_bin=0;
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
SET sql_log_bin=1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 0);
include/stop_slave.inc
......@@ -16,4 +14,47 @@ SELECT 1;
Got one of the listed errors
INSERT INTO t1 VALUES (1000, 3);
DROP TABLE t1;
*** Test crashing the master mysqld and check that binlog state is recovered. ***
include/stop_slave.inc
RESET MASTER;
CHANGE MASTER TO master_gtid_pos='';
RESET MASTER;
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid_list # # []
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
include/start_slave.inc
SET gtid_domain_id= 1;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
FLUSH LOGS;
SET gtid_domain_id= 2;
INSERT INTO t1 VALUES (3);
FLUSH LOGS;
show binary logs;
Log_name File_size
master-bin.000001 #
master-bin.000002 #
master-bin.000003 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000003 # Gtid_list # # [1-1-3,2-1-4,0-1-1]
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
SELECT 1;
Got one of the listed errors
show binary logs;
Log_name File_size
master-bin.000001 #
master-bin.000002 #
master-bin.000003 #
master-bin.000004 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000004 # Gtid_list # # [1-1-3,0-1-1,2-1-4]
SELECT * FROM t1 ORDER BY a;
a
1
2
3
DROP TABLE t1;
include/rpl_end.inc
......@@ -7,9 +7,7 @@
--echo *** Test crashing master, causing slave IO thread to reconnect while SQL thread is running ***
--connection server_1
SET sql_log_bin=0;
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
SET sql_log_bin=1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 0);
--save_master_pos
......@@ -46,6 +44,7 @@ while ($1)
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
--error 2006,2013
SELECT 1;
--source include/wait_until_disconnected.inc
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
......@@ -66,6 +65,65 @@ INSERT INTO t1 VALUES (1000, 3);
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1 WHERE b=3
--source include/wait_condition.inc
--connection server_1
DROP TABLE t1;
--save_master_pos
--echo *** Test crashing the master mysqld and check that binlog state is recovered. ***
--connection server_2
--sync_with_master
--source include/stop_slave.inc
RESET MASTER;
CHANGE MASTER TO master_gtid_pos='';
--connection server_1
RESET MASTER;
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 1,1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--connection server_2
--source include/start_slave.inc
--connection server_1
SET gtid_domain_id= 1;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
FLUSH LOGS;
SET gtid_domain_id= 2;
INSERT INTO t1 VALUES (3);
FLUSH LOGS;
--source include/show_binary_logs.inc
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
#--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait
EOF
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
--error 2006,2013
SELECT 1;
--source include/wait_until_disconnected.inc
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/show_binary_logs.inc
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
--save_master_pos
--connection server_2
--sync_with_master
SELECT * FROM t1 ORDER BY a;
--connection server_1
DROP TABLE t1;
......
......@@ -8225,6 +8225,7 @@ int TC_LOG_BINLOG::open(const char *opt_name)
sql_print_information("Recovering after a crash using %s", opt_name);
error= recover(&log_info, log_name, &log,
(Format_description_log_event *)ev);
state_read= true;
/* Pick the next unused seq_no from the recovered binlog state. */
bump_seq_no_counter_if_needed(
rpl_global_gtid_binlog_state.seq_no_from_state());
......
......@@ -396,7 +396,7 @@ class MYSQL_QUERY_LOG: public MYSQL_LOG
( ((ulong)(c)>>1) == BINLOG_COOKIE_DUMMY_ID )
class binlog_cache_mngr;
class rpl_gtid;
struct rpl_gtid;
class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
{
private:
......
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