Skip to content
Permalink
Browse files
Galera GTID support
Support for galera GTID consistency thru cluster. All nodes in cluster
should have same GTID for replicated events which are originating from cluster.
Cluster originating commands need to contain sequential WSREP GTID seqno
Ignore manual setting of gtid_seq_no=X.

In master-slave scenario where master is non galera node replicated GTID is
replicated and is preserved in all nodes.

To have this - domain_id, server_id and seqnos should be same on all nodes.
Node which bootstraps the cluster, to achieve this, sends domain_id and
server_id to other nodes and this combination is used to write GTID for events
that are replicated inside cluster.

Cluster nodes that are executing non replicated events are going to have different
GTID than replicated ones, difference will be visible in domain part of gtid.

With wsrep_gtid_domain_id you can set domain_id for WSREP cluster.

Functions WSREP_LAST_WRITTEN_GTID, WSREP_LAST_SEEN_GTID and
WSREP_SYNC_WAIT_UPTO_GTID now works with "native" GTID format.

Fixed galera tests to reflect this chances.

Add variable to manually update WSREP GTID seqno in cluster

Add variable to manipulate and change WSREP GTID seqno. Next command
originating from cluster and on same thread will have set seqno and
cluster should change their internal counter to it's value.
Behavior is same as using @@gtid_seq_no for non WSREP transaction.
  • Loading branch information
mkaruza authored and Jan Lindström committed Jan 29, 2020
1 parent 5defdc3 commit 41bc736
Show file tree
Hide file tree
Showing 52 changed files with 1,053 additions and 476 deletions.
@@ -21,8 +21,6 @@ MW-329 : MDEV-19962 Galera test failure on MW-329
MW-360 : needs rewrite to be MariaDB gtid compatible
galera.galera_defaults : MDEV-21494 Galera test sporadic failure on galera.galera_defaults
galera_account_management : MariaDB 10.0 does not support ALTER USER
galera_as_master_gtid : Requires MySQL GTID
galera_as_master_gtid_change_master : Requires MySQL GTID
galera_as_slave_gtid_myisam : MDEV-21421 galera.galera_as_slave_gtid_myisam
galera_as_slave_gtid_replicate_do_db_cc : Requires MySQL GTID
galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB
@@ -0,0 +1,28 @@
connection node_2;
connection node_1;
connection node_1;
create table t1(a int);
set @@wsrep_gtid_seq_no=22;
insert into t1 values(1);
insert into t1 values(2);
select @@gtid_binlog_state;
@@gtid_binlog_state
1-1-23
select wsrep_last_seen_gtid();
wsrep_last_seen_gtid()
1-1-23
select wsrep_last_written_gtid();
wsrep_last_written_gtid()
1-1-23
connection node_2;
select @@gtid_binlog_state;
@@gtid_binlog_state
1-1-23
select wsrep_last_seen_gtid();
wsrep_last_seen_gtid()
1-1-23
select wsrep_last_written_gtid();
wsrep_last_written_gtid()
1-1-0
connection node_1;
drop table t1;
@@ -1,22 +1,28 @@
START SLAVE USER='root';
Warnings:
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
connection node_2;
connection node_1;
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
START SLAVE;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
uuids_do_not_match
1
SELECT @@global.gtid_binlog_pos;
@@global.gtid_binlog_pos
100-1-2
connection node_2;
INSERT INTO t1 VALUES(2);
uuids_do_not_match
1
uuids_match
1
uuids_do_not_match
gtid_do_not_match
1
uuids_match
connection node_3;
gtid_do_not_match
1
connection node_1;
DROP TABLE t1;
connection node_3;
connection node_1;
connection node_2;
gtid_executed_equal
1
connection node_3;
gtid_executed_equal
1
STOP SLAVE;
@@ -1,15 +1,31 @@
START SLAVE USER='root';
Warnings:
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
connection node_2;
connection node_1;
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
START SLAVE;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
connection node_2;
INSERT INTO t1 VALUES(2);
connection node_3;
STOP SLAVE;
START SLAVE USER='root';
Warnings:
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
START SLAVE;
connection node_1;
INSERT INTO t1 VALUES(3);
connection node_2;
INSERT INTO t1 VALUES(4);
connection node_3;
connection node_1;
DROP TABLE t1;
connection node_3;
STOP SLAVE;
RESET SLAVE ALL;
RESET MASTER;
connection node_2;
SET GLOBAL wsrep_on=OFF;
RESET MASTER;
SET GLOBAL wsrep_on=ON;
connection node_1;
SET GLOBAL wsrep_on=OFF;
RESET MASTER;
SET GLOBAL wsrep_on=ON;
@@ -97,42 +97,42 @@ master-bin.000001 256 Gtid_list 1 285 []
master-bin.000001 285 Binlog_checkpoint 1 329 master-bin.000001
master-bin.000001 329 Gtid 3 371 GTID 0-3-1
master-bin.000001 371 Query 3 458 CREATE SCHEMA test1
master-bin.000001 458 Gtid 3 500 GTID 0-3-2
master-bin.000001 458 Gtid 3 500 GTID 0-3-3
master-bin.000001 500 Query 3 647 use `test1`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB
master-bin.000001 647 Gtid 3 689 BEGIN GTID 0-3-3
master-bin.000001 647 Gtid 3 689 BEGIN GTID 0-3-5
master-bin.000001 689 Annotate_rows 3 748 INSERT INTO test1.t1 (f1) VALUES (1)
master-bin.000001 748 Table_map 3 797 table_id: ### (test1.t1)
master-bin.000001 797 Write_rows_v1 3 839 table_id: ### flags: STMT_END_F
master-bin.000001 839 Xid 3 870 COMMIT /* xid=### */
master-bin.000001 870 Gtid 3 912 BEGIN GTID 0-3-4
master-bin.000001 870 Gtid 3 912 BEGIN GTID 0-3-7
master-bin.000001 912 Annotate_rows 3 971 INSERT INTO test1.t1 (f1) VALUES (2)
master-bin.000001 971 Table_map 3 1020 table_id: ### (test1.t1)
master-bin.000001 1020 Write_rows_v1 3 1062 table_id: ### flags: STMT_END_F
master-bin.000001 1062 Xid 3 1093 COMMIT /* xid=### */
master-bin.000001 1093 Gtid 3 1135 BEGIN GTID 0-3-5
master-bin.000001 1093 Gtid 3 1135 BEGIN GTID 0-3-9
master-bin.000001 1135 Annotate_rows 3 1194 INSERT INTO test1.t1 (f1) VALUES (3)
master-bin.000001 1194 Table_map 3 1243 table_id: ### (test1.t1)
master-bin.000001 1243 Write_rows_v1 3 1285 table_id: ### flags: STMT_END_F
master-bin.000001 1285 Xid 3 1316 COMMIT /* xid=### */
master-bin.000001 1316 Gtid 3 1358 BEGIN GTID 0-3-6
master-bin.000001 1316 Gtid 3 1358 BEGIN GTID 0-3-12
master-bin.000001 1358 Annotate_rows 3 1451 UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz'
master-bin.000001 1451 Table_map 3 1500 table_id: ### (test1.t1)
master-bin.000001 1500 Update_rows_v1 3 1588 table_id: ### flags: STMT_END_F
master-bin.000001 1588 Xid 3 1619 COMMIT /* xid=### */
master-bin.000001 1619 Gtid 3 1661 BEGIN GTID 0-3-7
master-bin.000001 1619 Gtid 3 1661 BEGIN GTID 0-3-13
master-bin.000001 1661 Annotate_rows 3 1795 DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3
master-bin.000001 1795 Table_map 3 1844 table_id: ### (test1.t1)
master-bin.000001 1844 Delete_rows_v1 3 1886 table_id: ### flags: STMT_END_F
master-bin.000001 1886 Xid 3 1917 COMMIT /* xid=### */
master-bin.000001 1917 Gtid 3 1959 BEGIN GTID 0-3-8
master-bin.000001 1917 Gtid 3 1959 BEGIN GTID 0-3-15
master-bin.000001 1959 Annotate_rows 3 2020 INSERT INTO test1.t1 (f1) VALUES (111)
master-bin.000001 2020 Table_map 3 2069 table_id: ### (test1.t1)
master-bin.000001 2069 Write_rows_v1 3 2111 table_id: ### flags: STMT_END_F
master-bin.000001 2111 Annotate_rows 3 2172 INSERT INTO test1.t1 (f1) VALUES (222)
master-bin.000001 2172 Table_map 3 2221 table_id: ### (test1.t1)
master-bin.000001 2221 Write_rows_v1 3 2263 table_id: ### flags: STMT_END_F
master-bin.000001 2263 Xid 3 2294 COMMIT /* xid=### */
master-bin.000001 2294 Gtid 3 2336 BEGIN GTID 0-3-9
master-bin.000001 2294 Gtid 3 2336 BEGIN GTID <effective_uuid>
master-bin.000001 2336 Annotate_rows 3 2397 INSERT INTO test1.t1 (f1) VALUES (333)
master-bin.000001 2397 Table_map 3 2446 table_id: ### (test1.t1)
master-bin.000001 2446 Write_rows_v1 3 2488 table_id: ### flags: STMT_END_F
@@ -157,3 +157,12 @@ connection node_1;
connection node_2;
STOP SLAVE;
RESET SLAVE ALL;
SET GLOBAL wsrep_on=OFF;
RESET MASTER;
SET GLOBAL wsrep_on=ON;
connection node_1;
SET GLOBAL wsrep_on=OFF;
RESET MASTER;
SET GLOBAL wsrep_on=ON;
connection node_3;
RESET MASTER;
@@ -1,5 +1,7 @@
connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_2;
SET GLOBAL wsrep_ignore_apply_errors=0;
SET SESSION wsrep_on=OFF;
@@ -19,12 +19,12 @@ INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
0-2-2,2-3-4
1-1-2,2-3-4
connection node_1;
INSERT INTO t1 VALUES(4);
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
1-1-1,2-3-4,2-2-6
1-1-3,2-3-4
connection node_3;
DROP TABLE t1,t2;
connection node_2;
@@ -25,14 +25,14 @@ INSERT INTO t2 VALUES(5,55);
INSERT INTO t2 VALUES(6,66);
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
0-2-3,2-3-4
1-1-3,2-3-4
#Connection 1
connection node_1;
INSERT INTO t2 VALUES(7,77);
INSERT INTO t2 VALUES(8,88);
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
1-1-2,2-3-4,2-2-7
1-1-5,2-3-4
#Connection 3
connection node_3;
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
@@ -100,12 +100,12 @@ node2_committed_before
connection node_1;
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
1-1-3,2-3-6,2-2-9
1-1-8,2-3-6
#Connection 2
connection node_2;
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
0-1-7,0-2-8,2-3-6
1-1-8,2-3-6
#Connection 3
connection node_3;
SET AUTOCOMMIT=ON;
@@ -134,15 +134,15 @@ count(*)
12
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
0-1-7,0-2-11,2-3-7
1-1-11,2-3-7
#Connection 1
connection node_1;
SELECT count(*) from t1;
count(*)
12
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state
1-1-3,2-3-7,2-2-12
1-1-11,2-3-7
#Connection 3
connection node_3;
DROP TABLE t2,t1;
@@ -0,0 +1,44 @@
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
connection node_1;
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO t1 VALUES(1);
connection node_2;
SET AUTOCOMMIT = OFF;
SET @@wsrep_gtid_seq_no = 100;
START TRANSACTION;
INSERT INTO t1 VALUES(1);
connection node_1;
COMMIT;
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2a;
connection node_2;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Expected GTID value 1-1-2 on both nodes
SELECT @@gtid_binlog_state;
@@gtid_binlog_state
1-1-2
SET AUTOCOMMIT = ON;
INSERT INTO t1 VALUES(2);
# Expected GTID value 1-1-100 on both nodes, seqno is set with wsrep_gtid_seq_no
SELECT @@gtid_binlog_state;
@@gtid_binlog_state
1-1-100
connection node_1;
SELECT @@gtid_binlog_state;
@@gtid_binlog_state
1-1-100
SET AUTOCOMMIT = ON;
INSERT INTO t1 VALUES(3);
# Expected GTID value 1-1-101 on both nodes
SELECT @@gtid_binlog_state;
@@gtid_binlog_state
1-1-101
connection node_2;
SELECT @@gtid_binlog_state;
@@gtid_binlog_state
1-1-101
DROP TABLE t1;
@@ -1,38 +1,35 @@
connection node_2;
connection node_1;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
wsrep_last_committed_id_match
1
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connection node_1a;
SELECT WSREP_LAST_WRITTEN_GTID();
WSREP_LAST_WRITTEN_GTID()
100-1-0
connection node_1;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connection node_1;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;;
connection node_1a;
INSERT INTO t1 VALUES (1);
SELECT WSREP_LAST_WRITTEN_GTID() != '100-1-2' AS wsrep_written_does_not_match_different_conn;
wsrep_written_does_not_match_different_conn
1
connection node_2;
SELECT WSREP_LAST_WRITTEN_GTID() != '100-1-2' AS wsrep_written_does_not_match_different_nodes;
wsrep_written_does_not_match_different_nodes
1
connection node_1;
wsrep_last_committed_id_match
INSERT INTO t1 VALUES (1);
connection node_2;
wsrep_last_written_seen_id_match
1
connection node_1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
INSERT INTO t1 VALUES (1);
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
WSREP_LAST_SEEN_GTID() = '100-1-3'
1
wsrep_last_committed_id_match
wsrep_last_written_id_match
1
COMMIT;
wsrep_last_committed_id_advanced
1
wsrep_last_committed_id_advanced
wsrep_last_written_id_advanced
1
SET AUTOCOMMIT=ON;
DROP TABLE t1;
@@ -17,6 +17,7 @@ name wait/synch/mutex/sql/LOCK_wsrep_config_state
name wait/synch/mutex/sql/LOCK_wsrep_desync
name wait/synch/mutex/sql/LOCK_wsrep_donor_monitor
name wait/synch/mutex/sql/LOCK_wsrep_group_commit
name wait/synch/mutex/sql/LOCK_wsrep_gtid_wait_upto
name wait/synch/mutex/sql/LOCK_wsrep_joiner_monitor
name wait/synch/mutex/sql/LOCK_wsrep_ready
name wait/synch/mutex/sql/LOCK_wsrep_replaying

0 comments on commit 41bc736

Please sign in to comment.