Commit d943ed2c authored by Andrei Elkin's avatar Andrei Elkin

MDEV-7974 review/contribution:

gtid record of XA-prepare should no be merged into the replicated
trx. This patch redirects it into the default mysql.gtid_slave_pos table. A test is added.
parent 20b444ad
include/master-slave.inc
[connection master]
connection master;
create table t1 (a int, b int) engine=InnoDB;
xa start 't';
insert into t1 values(1, 2);
xa end 't';
xa prepare 't';
xa commit 't';
select * from t1;
a b
1 2
connection slave;
select * from t1;
a b
1 2
include/diff_tables.inc [master:t1, slave:t1]
connection master;
xa start 't';
insert into t1 values(3, 4);
xa end 't';
xa prepare 't';
xa rollback 't';
select * from t1;
a b
1 2
connection slave;
select * from t1;
a b
1 2
include/diff_tables.inc [master:t1, slave:t1]
connection master;
SET pseudo_slave_mode=1;
create table t2 (a int) engine=InnoDB;
......@@ -37,26 +28,20 @@ xa start 's';
insert into t2 values (0);
xa end 's';
xa prepare 's';
include/sync_with_master_gtid.inc
xa recover;
formatID gtrid_length bqual_length data
1 1 0 t
1 1 0 s
connection master;
xa commit 't';
xa commit 's';
SET pseudo_slave_mode=0;
Warnings:
Warning 1231 Slave applier execution mode not active, statement ineffective.
select * from t1;
a b
1 2
5 6
select * from t2;
a
0
connection slave;
select * from t1;
a b
1 2
5 6
select * from t2;
a
0
include/diff_tables.inc [master:t1, slave:t1]
include/diff_tables.inc [master:t2, slave:t2]
connection master;
drop table t1, t2;
include/rpl_end.inc
include/master-slave.inc
[connection master]
connection slave;
call mtr.add_suppression("The automatically created table.*name may not be entirely in lowercase");
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=slave_pos;
SET @@global.gtid_pos_auto_engines="innodb";
include/start_slave.inc
connection master;
create table t1 (a int, b int) engine=InnoDB;
insert into t1 values(0, 0);
xa start 't';
insert into t1 values(1, 2);
xa end 't';
xa prepare 't';
xa commit 't';
connection slave;
include/diff_tables.inc [master:t1, slave:t1]
connection master;
xa start 't';
insert into t1 values(3, 4);
xa end 't';
xa prepare 't';
xa rollback 't';
connection slave;
include/diff_tables.inc [master:t1, slave:t1]
connection master;
SET pseudo_slave_mode=1;
create table t2 (a int) engine=InnoDB;
xa start 't';
insert into t1 values (5, 6);
xa end 't';
xa prepare 't';
xa start 's';
insert into t2 values (0);
xa end 's';
xa prepare 's';
connection slave;
include/sync_with_master_gtid.inc
SELECT @@global.gtid_slave_pos = CONCAT(domain_id,"-",server_id,"-",seq_no) FROM mysql.gtid_slave_pos WHERE seq_no = (SELECT DISTINCT max(seq_no) FROM mysql.gtid_slave_pos);
@@global.gtid_slave_pos = CONCAT(domain_id,"-",server_id,"-",seq_no)
1
xa recover;
formatID gtrid_length bqual_length data
1 1 0 t
1 1 0 s
connection master;
xa commit 't';
xa commit 's';
SET pseudo_slave_mode=0;
Warnings:
Warning 1231 Slave applier execution mode not active, statement ineffective.
connection slave;
include/diff_tables.inc [master:t1, slave:t1]
include/diff_tables.inc [master:t2, slave:t2]
connection master;
drop table t1, t2;
connection slave;
include/stop_slave.inc
SET @@global.gtid_pos_auto_engines="";
SET @@session.sql_log_bin=0;
DROP TABLE mysql.gtid_slave_pos_InnoDB;
SET @@session.sql_log_bin=1;
include/start_slave.inc
include/rpl_end.inc
#
# This "body" file checks general properties of XA transaction replication
# as of MDEV-7974.
# Parameters:
# --let rpl_xa_check= SELECT ...
#
connection master;
create table t1 (a int, b int) engine=InnoDB;
insert into t1 values(0, 0);
xa start 't';
insert into t1 values(1, 2);
xa end 't';
xa prepare 't';
xa commit 't';
sync_slave_with_master;
let $diff_tables= master:t1, slave:t1;
source include/diff_tables.inc;
connection master;
xa start 't';
insert into t1 values(3, 4);
xa end 't';
xa prepare 't';
xa rollback 't';
sync_slave_with_master;
let $diff_tables= master:t1, slave:t1;
source include/diff_tables.inc;
connection master;
SET pseudo_slave_mode=1;
create table t2 (a int) engine=InnoDB;
xa start 't';
insert into t1 values (5, 6);
xa end 't';
xa prepare 't';
xa start 's';
insert into t2 values (0);
xa end 's';
xa prepare 's';
connection slave;
source include/sync_with_master_gtid.inc;
if ($rpl_xa_check)
{
--eval $rpl_xa_check
if ($rpl_xa_verbose)
{
--eval SELECT $rpl_xa_check_lhs
--eval SELECT $rpl_xa_check_rhs
}
}
xa recover;
connection master;
xa commit 't';
xa commit 's';
SET pseudo_slave_mode=0;
sync_slave_with_master;
let $diff_tables= master:t1, slave:t1;
source include/diff_tables.inc;
let $diff_tables= master:t2, slave:t2;
source include/diff_tables.inc;
connection master;
drop table t1, t2;
source include/have_innodb.inc;
source include/master-slave.inc;
create table t1 (a int, b int) engine=InnoDB;
xa start 't';
insert into t1 values(1, 2);
xa end 't';
xa prepare 't';
xa commit 't';
select * from t1;
sync_slave_with_master;
select * from t1;
connection master;
xa start 't';
insert into t1 values(3, 4);
xa end 't';
xa prepare 't';
xa rollback 't';
select * from t1;
sync_slave_with_master;
select * from t1;
connection master;
SET pseudo_slave_mode=1;
create table t2 (a int) engine=InnoDB;
xa start 't';
insert into t1 values (5, 6);
xa end 't';
xa prepare 't';
xa start 's';
insert into t2 values (0);
xa end 's';
xa prepare 's';
xa commit 't';
xa commit 's';
SET pseudo_slave_mode=0;
select * from t1;
select * from t2;
sync_slave_with_master;
select * from t1;
select * from t2;
connection master;
drop table t1, t2;
source rpl_xa.inc;
source include/rpl_end.inc;
--source include/have_innodb.inc
--source include/master-slave.inc
--connection slave
call mtr.add_suppression("The automatically created table.*name may not be entirely in lowercase");
--source include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=slave_pos;
SET @@global.gtid_pos_auto_engines="innodb";
--source include/start_slave.inc
--let $rpl_xa_check_lhs= @@global.gtid_slave_pos
--let $rpl_xa_check_rhs= CONCAT(domain_id,"-",server_id,"-",seq_no) FROM mysql.gtid_slave_pos WHERE seq_no = (SELECT DISTINCT max(seq_no) FROM mysql.gtid_slave_pos)
--let $rpl_xa_check=SELECT $rpl_xa_check_lhs = $rpl_xa_check_rhs
--source rpl_xa.inc
--connection slave
--source include/stop_slave.inc
SET @@global.gtid_pos_auto_engines="";
SET @@session.sql_log_bin=0;
DROP TABLE mysql.gtid_slave_pos_InnoDB;
SET @@session.sql_log_bin=1;
--source include/start_slave.inc
--source include/rpl_end.inc
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