maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #11029
Re: Mdev-10715 Initial Patch
Hi Andrei!
Thanks for the review.
On Thu, Oct 12, 2017 at 11:48 PM, <andrei.elkin@xxxxxxxxxx> wrote:
> Howdy, Sachin!
>
> I've checked the patch mostly from the high-level design pov to gather
> few suggestions. Find them on the top of diff hunks (hopefully the diff
> remains applicable) below indented with '*review*>'.
>
>
>
> revision-id: daf9a67ea13c5c7309f85a104e7c07ec68f65e88 (mariadb-10.1.28-10-gdaf9a67)
> parent(s): 5eb666ad37ff80e5f8dc714bb68fcb1e269b797a
> author: Sachin Setiya
> committer: Sachin Setiya
> timestamp: 2017-10-10 17:45:21 +0530
> message:
>
> Mdev-10715 Initial Patch
> *review*> The initial patch is a very good time to write down the work
> intent and its key features.
Done
> Could you please do that and highlight how WSREP has really
> become multi-source compatible.
>
>
> ---
> mysql-test/suite/galera/r/galera_gtid_slave.result | 18 +++
> .../r/galera_gtid_slave_sst_mysqldump.result | 92 ++++++++++++
> .../galera/r/galera_gtid_slave_sst_rsync.result | 92 ++++++++++++
> mysql-test/suite/galera/t/galera_gtid_slave.cnf | 18 +++
> mysql-test/suite/galera/t/galera_gtid_slave.test | 67 +++++++++
> .../galera/t/galera_gtid_slave_sst_mysqldump.cnf | 18 +++
> .../galera/t/galera_gtid_slave_sst_mysqldump.test | 156 +++++++++++++++++++++
> .../suite/galera/t/galera_gtid_slave_sst_rsync.cnf | 19 +++
> .../galera/t/galera_gtid_slave_sst_rsync.test | 156 +++++++++++++++++++++
> sql/log.cc | 37 ++++-
> sql/wsrep_mysqld.cc | 9 ++
> 11 files changed, 681 insertions(+), 1 deletion(-)
>
> diff --git a/mysql-test/suite/galera/r/galera_gtid_slave.result b/mysql-test/suite/galera/r/galera_gtid_slave.result
> new file mode 100644
> index 0000000..7ab10c7
> --- /dev/null
> +++ b/mysql-test/suite/galera/r/galera_gtid_slave.result
> @@ -0,0 +1,18 @@
> +START SLAVE;
> +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
> +INSERT INTO t1 VALUES(1);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-2
> +INSERT INTO t1 VALUES(2);
> +INSERT INTO t1 VALUES(3);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-2,2-2-2
> +INSERT INTO t1 VALUES(4);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-2,2-2-2,2-3-3
> +DROP TABLE t1;
> +STOP SLAVE;
> +RESET SLAVE ALL;
> diff --git a/mysql-test/suite/galera/r/galera_gtid_slave_sst_mysqldump.result b/mysql-test/suite/galera/r/galera_gtid_slave_sst_mysqldump.result
> new file mode 100644
> index 0000000..8e8e2e0
> --- /dev/null
> +++ b/mysql-test/suite/galera/r/galera_gtid_slave_sst_mysqldump.result
> @@ -0,0 +1,92 @@
> +START SLAVE;
> +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 int unique) ENGINE=InnoDB;
> +INSERT INTO t2 VALUES(1,11);
> +INSERT INTO t2 VALUES(2,22);
> +INSERT INTO t2 VALUES(3,33);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-4
> +INSERT INTO t2 VALUES(4,44);
> +INSERT INTO t2 VALUES(5,55);
> +INSERT INTO t2 VALUES(6,66);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-4,2-2-3
> +INSERT INTO t2 VALUES(7,77);
> +INSERT INTO t2 VALUES(8,88);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-4,2-2-3,2-3-5
> +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +COMMIT;
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +COMMIT;
> +Shutting down server ...
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +COMMIT;
> +Starting server ...
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +COMMIT;
> +Select * from t1 order by f1;
> +f1
> +node1_committed_before
> +node1_committed_before
> +node1_committed_during
> +node1_committed_during
> +node2_committed_before
> +node2_committed_before
> +node3_committed_after
> +node3_committed_after
> +Select * from t1 order by f1;
> +f1
> +node1_committed_before
> +node1_committed_before
> +node1_committed_during
> +node1_committed_during
> +node2_committed_before
> +node2_committed_before
> +node3_committed_after
> +node3_committed_after
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-6,2-2-7,2-3-8
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-6,2-2-7,2-3-8
> +SET AUTOCOMMIT=ON;
> +SET AUTOCOMMIT=ON;
> +SET AUTOCOMMIT=ON;
> +STOP slave;
> +INSERT INTO t1 VALUES ('node2_slave_stoped');
> +INSERT INTO t1 VALUES ('node1_slave_stoped');
> +INSERT INTO t1 VALUES ('node2_slave_stoped_inserted');
> +start slave;
> +INSERT INTO t1 VALUES ('node2_slave_started');
> +SELECT COUNT(*) from t1;
> +COUNT(*)
> +11
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-6,2-3-8,2-2-11
> +SELECT COUNT(*) from t1;
> +COUNT(*)
> +11
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-6,2-3-8,2-2-11
> +DROP TABLE t2,t1;
> +STOP SLAVE;
> +RESET SLAVE ALL;
> diff --git a/mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result b/mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result
> new file mode 100644
> index 0000000..9ab4601
> --- /dev/null
> +++ b/mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result
> @@ -0,0 +1,92 @@
> +START SLAVE;
> +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 int unique) ENGINE=InnoDB;
> +INSERT INTO t2 VALUES(1,11);
> +INSERT INTO t2 VALUES(2,22);
> +INSERT INTO t2 VALUES(3,33);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-4
> +INSERT INTO t2 VALUES(4,44);
> +INSERT INTO t2 VALUES(5,55);
> +INSERT INTO t2 VALUES(6,66);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-4,2-2-3
> +INSERT INTO t2 VALUES(7,77);
> +INSERT INTO t2 VALUES(8,88);
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-4,2-2-3,2-3-5
> +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +COMMIT;
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +COMMIT;
> +Shutting down server ...
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +COMMIT;
> +Starting server ...
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +COMMIT;
> +Select * from t1 order by f1;
> +f1
> +node1_committed_before
> +node1_committed_before
> +node1_committed_during
> +node1_committed_during
> +node2_committed_before
> +node2_committed_before
> +node3_committed_after
> +node3_committed_after
> +Select * from t1 order by f1;
> +f1
> +node1_committed_before
> +node1_committed_before
> +node1_committed_during
> +node1_committed_during
> +node2_committed_before
> +node2_committed_before
> +node3_committed_after
> +node3_committed_after
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-6,2-2-7,2-3-8
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-6,2-2-7,2-3-8
> +SET AUTOCOMMIT=ON;
> +SET AUTOCOMMIT=ON;
> +SET AUTOCOMMIT=ON;
> +STOP slave;
> +INSERT INTO t1 VALUES ('node2_slave_stoped');
> +INSERT INTO t1 VALUES ('node1_slave_stoped');
> +INSERT INTO t1 VALUES ('node2_slave_stoped_inserted');
> +start slave;
> +INSERT INTO t1 VALUES ('node2_slave_started');
> +SELECT COUNT(*) from t1;
> +COUNT(*)
> +11
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-7,2-3-8,2-2-11
> +SELECT COUNT(*) from t1;
> +COUNT(*)
> +12
> +SELECT @@global.gtid_binlog_state;
> +@@global.gtid_binlog_state
> +1-1-7,2-3-8,2-2-11
> +DROP TABLE t2,t1;
> +STOP SLAVE;
> +RESET SLAVE ALL;
> diff --git a/mysql-test/suite/galera/t/galera_gtid_slave.cnf b/mysql-test/suite/galera/t/galera_gtid_slave.cnf
> new file mode 100644
> index 0000000..409d0d1
> --- /dev/null
> +++ b/mysql-test/suite/galera/t/galera_gtid_slave.cnf
> @@ -0,0 +1,18 @@
> +!include ../galera_2nodes_as_slave.cnf
> +
> +[mysqld]
> +log-bin=mysqld-bin
> +log-slave-updates
> +binlog-format=ROW
> +
> +[mysqld.1]
> +gtid-domain-id=1
> +[mysqld.2]
> +gtid-domain-id=2
> +wsrep_gtid_mode=1
> +wsrep_gtid_domain_id=2
> +[mysqld.3]
> +gtid-domain-id=2
> +wsrep_gtid_mode=1
> +wsrep_gtid_domain_id=2
> +
> diff --git a/mysql-test/suite/galera/t/galera_gtid_slave.test b/mysql-test/suite/galera/t/galera_gtid_slave.test
> new file mode 100644
> index 0000000..3b3f6f3
> --- /dev/null
> +++ b/mysql-test/suite/galera/t/galera_gtid_slave.test
> @@ -0,0 +1,67 @@
> +#
> +# Test Galera as a slave to a MariaDB master using GTIDs
> +#
> +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes
> +# suite/galera/t/galera_as_slave_gtid.cnf has the GTID options
> +#
> +# In addition to performing DDL and DML, we check that the gtid of the master is preserved inside the cluster
> +#
> +
> +--source include/have_innodb.inc
> +
> +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
> +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
> +--source include/galera_cluster.inc
> +
> +--connection node_2
> +--disable_query_log
> +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
> +--enable_query_log
> +START SLAVE;
> +
> +--connection node_1
> +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
> +INSERT INTO t1 VALUES(1);
> +
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_2
> +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
> +--source include/wait_condition.inc
> +
> +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
> +--source include/wait_condition.inc
> +INSERT INTO t1 VALUES(2);
> +INSERT INTO t1 VALUES(3);
> +SELECT @@global.gtid_binlog_state;
> +
> +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
> +--sleep 1
> +--let $wait_condition = SELECT COUNT(*) = 3 FROM t1;
> +--source include/wait_condition.inc
> +
> +INSERT INTO t1 VALUES(4);
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_1
> +DROP TABLE t1;
> +
> +#
> +# Unfortunately without the sleep below the following statement fails with "query returned no rows", which
> +# is difficult to understand given that it is an aggregate query. A "query execution was interrupted"
> +# warning is also reported by MTR, which is also weird.
> +#
> +
> +--sleep 1
> +
> +--connection node_2
> +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
> +--source include/wait_condition.inc
> +
> +--connection node_3
> +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
> +--source include/wait_condition.inc
> +
> +--connection node_2
> +STOP SLAVE;
> +RESET SLAVE ALL;
> diff --git a/mysql-test/suite/galera/t/galera_gtid_slave_sst_mysqldump.cnf b/mysql-test/suite/galera/t/galera_gtid_slave_sst_mysqldump.cnf
> new file mode 100644
> index 0000000..409d0d1
> --- /dev/null
> +++ b/mysql-test/suite/galera/t/galera_gtid_slave_sst_mysqldump.cnf
> @@ -0,0 +1,18 @@
> +!include ../galera_2nodes_as_slave.cnf
> +
> +[mysqld]
> +log-bin=mysqld-bin
> +log-slave-updates
> +binlog-format=ROW
> +
> +[mysqld.1]
> +gtid-domain-id=1
> +[mysqld.2]
> +gtid-domain-id=2
> +wsrep_gtid_mode=1
> +wsrep_gtid_domain_id=2
> +[mysqld.3]
> +gtid-domain-id=2
> +wsrep_gtid_mode=1
> +wsrep_gtid_domain_id=2
> +
> diff --git a/mysql-test/suite/galera/t/galera_gtid_slave_sst_mysqldump.test b/mysql-test/suite/galera/t/galera_gtid_slave_sst_mysqldump.test
> new file mode 100644
> index 0000000..67aad21
> --- /dev/null
> +++ b/mysql-test/suite/galera/t/galera_gtid_slave_sst_mysqldump.test
> @@ -0,0 +1,156 @@
> +#
> +# Test Galera as a slave to a MariaDB master using GTIDs
> +#
> +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes
> +# suite/galera/t/galera_as_slave_gtid.cnf has the GTID options
> +#
> +# In addition to performing DDL and DML, we check that the gtid of the master is preserved inside the cluster
> +#
> +
> +--source include/big_test.inc
> +--source include/have_innodb.inc
> +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
> +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
> +--source include/galera_cluster.inc
> +
> +--connection node_2
> +--disable_query_log
> +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
> +--enable_query_log
> +START SLAVE;
> +
> +--connection node_1
> +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 int unique) ENGINE=InnoDB;
> +INSERT INTO t2 VALUES(1,11);
> +INSERT INTO t2 VALUES(2,22);
> +INSERT INTO t2 VALUES(3,33);
> +
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_2
> +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
> +--source include/wait_condition.inc
> +
> +--let $wait_condition = SELECT COUNT(*) = 3 FROM t2;
> +--source include/wait_condition.inc
> +INSERT INTO t2 VALUES(4,44);
> +INSERT INTO t2 VALUES(5,55);
> +INSERT INTO t2 VALUES(6,66);
> +SELECT @@global.gtid_binlog_state;
> +
> +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
> +--sleep 1
> +--let $wait_condition = SELECT COUNT(*) = 6 FROM t2;
> +--source include/wait_condition.inc
> +
> +INSERT INTO t2 VALUES(7,77);
> +INSERT INTO t2 VALUES(8,88);
> +SELECT @@global.gtid_binlog_state;
> +
> +#Perform SST
> +--connection node_1
> +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +COMMIT;
> +
> +--connection node_2
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +COMMIT;
> +
> +--connection node_3
> +--echo Shutting down server ...
> +--source include/shutdown_mysqld.inc
> +
> +
> +--connection node_2
> +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
> +--source include/wait_condition.inc
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +COMMIT;
> +
> +--connection node_3
> +--echo Starting server ...
> +--source include/start_mysqld.inc
> +--source include/wait_until_ready.inc
> +
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +COMMIT;
> +
> +--connection node_2
> +Select * from t1 order by f1;
> +
> +--connection node_3
> +Select * from t1 order by f1;
> +
> +#SST Done
> +--sleep 1
> +--connection node_2
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_3
> +SELECT @@global.gtid_binlog_state;
> +
> +#
> +#stop slave on node 2
> +--connection node_1
> +SET AUTOCOMMIT=ON;
> +#drop table t1;
> +#CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
> +
> +--connection node_2
> +SET AUTOCOMMIT=ON;
> +--connection node_3
> +SET AUTOCOMMIT=ON;
> +
> +--connection node_2
> +STOP slave;
> +--sleep 1
> +INSERT INTO t1 VALUES ('node2_slave_stoped');
> +
> +--connection node_1
> +INSERT INTO t1 VALUES ('node1_slave_stoped');
> +#start slave
> +--connection node_2
> +INSERT INTO t1 VALUES ('node2_slave_stoped_inserted');
> +start slave;
> +INSERT INTO t1 VALUES ('node2_slave_started');
> +SELECT COUNT(*) from t1;
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_3
> +SELECT COUNT(*) from t1;
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_1
> +DROP TABLE t2,t1;
> +
> +# Unfortunately without the sleep below the following statement fails with "query returned no rows", which
> +# is difficult to understand given that it is an aggregate query. A "query execution was interrupted"
> +# warning is also reported by MTR, which is also weird.
> +#
> +
> +--sleep 3
> +
> +--connection node_2
> +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
> +--source include/wait_condition.inc
> +
> +--connection node_3
> +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
> +--source include/wait_condition.inc
> +
> +--connection node_2
> +STOP SLAVE;
> +RESET SLAVE ALL;
> diff --git a/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf
> new file mode 100644
> index 0000000..2c82531
> --- /dev/null
> +++ b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf
> @@ -0,0 +1,19 @@
> +!include ../galera_2nodes_as_slave.cnf
> +
> +[mysqld]
> +log-bin=mysqld-bin
> +log-slave-updates
> +binlog-format=ROW
> +wsrep_sst_method=rsync
> +
> +[mysqld.1]
> +gtid-domain-id=1
> +[mysqld.2]
> +gtid-domain-id=2
> +wsrep_gtid_mode=1
> +wsrep_gtid_domain_id=2
> +[mysqld.3]
> +gtid-domain-id=2
> +wsrep_gtid_mode=1
> +wsrep_gtid_domain_id=2
> +
> diff --git a/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test
> new file mode 100644
> index 0000000..67aad21
> --- /dev/null
> +++ b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test
> @@ -0,0 +1,156 @@
> +#
> +# Test Galera as a slave to a MariaDB master using GTIDs
> +#
> +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes
> +# suite/galera/t/galera_as_slave_gtid.cnf has the GTID options
> +#
> +# In addition to performing DDL and DML, we check that the gtid of the master is preserved inside the cluster
> +#
> +
> +--source include/big_test.inc
> +--source include/have_innodb.inc
> +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
> +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
> +--source include/galera_cluster.inc
> +
> +--connection node_2
> +--disable_query_log
> +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
> +--enable_query_log
> +START SLAVE;
> +
> +--connection node_1
> +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 int unique) ENGINE=InnoDB;
> +INSERT INTO t2 VALUES(1,11);
> +INSERT INTO t2 VALUES(2,22);
> +INSERT INTO t2 VALUES(3,33);
> +
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_2
> +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
> +--source include/wait_condition.inc
> +
> +--let $wait_condition = SELECT COUNT(*) = 3 FROM t2;
> +--source include/wait_condition.inc
> +INSERT INTO t2 VALUES(4,44);
> +INSERT INTO t2 VALUES(5,55);
> +INSERT INTO t2 VALUES(6,66);
> +SELECT @@global.gtid_binlog_state;
> +
> +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
> +--sleep 1
> +--let $wait_condition = SELECT COUNT(*) = 6 FROM t2;
> +--source include/wait_condition.inc
> +
> +INSERT INTO t2 VALUES(7,77);
> +INSERT INTO t2 VALUES(8,88);
> +SELECT @@global.gtid_binlog_state;
> +
> +#Perform SST
> +--connection node_1
> +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +INSERT INTO t1 VALUES ('node1_committed_before');
> +COMMIT;
> +
> +--connection node_2
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +INSERT INTO t1 VALUES ('node2_committed_before');
> +COMMIT;
> +
> +--connection node_3
> +--echo Shutting down server ...
> +--source include/shutdown_mysqld.inc
> +
> +
> +--connection node_2
> +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
> +--source include/wait_condition.inc
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +INSERT INTO t1 VALUES ('node1_committed_during');
> +COMMIT;
> +
> +--connection node_3
> +--echo Starting server ...
> +--source include/start_mysqld.inc
> +--source include/wait_until_ready.inc
> +
> +SET AUTOCOMMIT=OFF;
> +START TRANSACTION;
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +INSERT INTO t1 VALUES ('node3_committed_after');
> +COMMIT;
> +
> +--connection node_2
> +Select * from t1 order by f1;
> +
> +--connection node_3
> +Select * from t1 order by f1;
> +
> +#SST Done
> +--sleep 1
> +--connection node_2
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_3
> +SELECT @@global.gtid_binlog_state;
> +
> +#
> +#stop slave on node 2
> +--connection node_1
> +SET AUTOCOMMIT=ON;
> +#drop table t1;
> +#CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
> +
> +--connection node_2
> +SET AUTOCOMMIT=ON;
> +--connection node_3
> +SET AUTOCOMMIT=ON;
> +
> +--connection node_2
> +STOP slave;
> +--sleep 1
> +INSERT INTO t1 VALUES ('node2_slave_stoped');
> +
> +--connection node_1
> +INSERT INTO t1 VALUES ('node1_slave_stoped');
> +#start slave
> +--connection node_2
> +INSERT INTO t1 VALUES ('node2_slave_stoped_inserted');
> +start slave;
> +INSERT INTO t1 VALUES ('node2_slave_started');
> +SELECT COUNT(*) from t1;
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_3
> +SELECT COUNT(*) from t1;
> +SELECT @@global.gtid_binlog_state;
> +
> +--connection node_1
> +DROP TABLE t2,t1;
> +
> +# Unfortunately without the sleep below the following statement fails with "query returned no rows", which
> +# is difficult to understand given that it is an aggregate query. A "query execution was interrupted"
> +# warning is also reported by MTR, which is also weird.
> +#
> +
> +--sleep 3
> +
> +--connection node_2
> +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
> +--source include/wait_condition.inc
> +
> +--connection node_3
> +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
> +--source include/wait_condition.inc
> +
> +--connection node_2
> +STOP SLAVE;
> +RESET SLAVE ALL;
>
> *review*> The better timing for the non-zero seq_no Gtid write deems to
> inside THD::binlog_start_trans_and_stmt() invoked few instructions
> earlier. This method is invoked once per *transaction* which
> guarantees no duplication which the current chosen point seems to
> concede. Perhaps you change its singature to pass the writer.
Done as we discussed. this is added into binlog_statrt_trans_and_stmt()
And I am checking for ha_info->is_started().
> Also I think we may write the non-zero seq_no Gtid generally, regardless
> of WITH_WSREP (naturally to block doing that later at binlog commit
> phase, also commented below).
This commit will go into 10.1 so as we discussed , we can do this later in 10.3.
>
> diff --git a/sql/log.cc b/sql/log.cc
> index a9f486d..53eeadf 100644
> --- a/sql/log.cc
> +++ b/sql/log.cc
> @@ -5655,6 +5655,23 @@ int THD::binlog_write_table_map(TABLE *table, bool is_transactional,
> DBUG_RETURN(error);
> }
> }
> +#ifdef WITH_WSREP
> + /* Get domain id only when gtid mode is set
> + If this event is replicate through a master then ,
> + we will forward the same gtid another nodes
> + */
> + if (wsrep_gtid_mode && this->variables.gtid_seq_no)
> + {
> + Gtid_log_event gtid_event(this, this->variables.gtid_seq_no,
> + this->variables.gtid_domain_id,
> + true, LOG_EVENT_SUPPRESS_USE_F,
> + true, 0);
> + gtid_event.server_id= this->variables.server_id;
> +
> + if ((error= writer.write(>id_event)))
> + DBUG_RETURN(error);
> + }
> +#endif
> if ((error= writer.write(&the_event)))
> DBUG_RETURN(error);
>
> @@ -5826,7 +5843,7 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone,
> DBUG_PRINT("enter", ("standalone: %d", standalone));
>
> #ifdef WITH_WSREP
> - if (WSREP(thd) && thd->wsrep_trx_meta.gtid.seqno != -1 && wsrep_gtid_mode)
> + if (WSREP(thd) && thd->wsrep_trx_meta.gtid.seqno != -1 && wsrep_gtid_mode && !thd->variables.gtid_seq_no)
> {
> domain_id= wsrep_gtid_domain_id;
> } else {
>
> *review*> I'm suggest we check the non-zero seq_no status in
> MYSQL_BIN_LOG::write_gtid_event()
>
> *review*>diff --git a/sql/log.cc b/sql/log.cc
> *review*>index 2fcb6f6dbf6..8229426a5bd 100644
> *review*>--- a/sql/log.cc
> *review*>+++ b/sql/log.cc
> *review*>@@ -5867,7 +5867,6 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone,
> *review*> err= rpl_global_gtid_binlog_state.update_with_next_gtid(domain_id,
> *review*> local_server_id, >id);
> *review*> seq_no= gtid.seq_no;
> *review*>- }
> *review*> if (err)
> *review*> DBUG_RETURN(true);
> *review*> thd->last_commit_gtid= gtid;
> *review*>@@ -5880,6 +5879,7 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone,
> *review*> DBUG_ASSERT(this == &mysql_bin_log);
> *review*> if (write_event(>id_event))
> *review*> DBUG_RETURN(true);
> *review*>+ }
> *review*> status_var_add(thd->status_var.binlog_bytes_written, gtid_event.data_written);
> *review*>
> *review*> DBUG_RETURN(false);
>
> *review*> so only the zero auto-evaluated seq_no Gtid would make to the
> method you're trying to patch. And the hunk is unneeded in this
> case. Like above we generalize WITH_WSREP away.
>
^^^^^^^
I am not sure about this hunk , I think this was mistake. I have
reverted this change.
> @@ -6718,6 +6735,24 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
> mysql_mutex_assert_owner(&LOCK_log);
> if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
> DBUG_RETURN(ER_ERROR_ON_WRITE);
> + uchar *read_pos= cache->read_pos;
> +
> +#ifdef WITH_WSREP
> + /*
> + In the cache we have gtid event if , below condition is true,
> + then we will simply increment the read position of cache by
> + the length of Gtid_log_event.
> + */
> + if (wsrep_gtid_mode && thd->variables.gtid_seq_no)
> + {
> + uchar *head= read_pos;
> + uint data_len= uint4korr(head + EVENT_LEN_OFFSET);
> + uint event_type= (uchar)head[EVENT_TYPE_OFFSET];
> + if (event_type == GTID_LOG_EVENT)
> + cache->read_pos+= data_len;
> + }
> +#endif
> +
> uint length= my_b_bytes_in_cache(cache), group, carry, hdr_offs;
> long val;
> ulong end_log_pos_inc= 0; // each event processed adds BINLOG_CHECKSUM_LEN 2 t
>
> *review*> The following block is fine *but* we shall explain
> what is GTID_SUPPORT, whether it actually for us.
>
Well , there is no such thing as GTID_SUPPORT :( , we are using ifdef
without even defining gtid_support
╭─sachin@sachin-desk ~/10715/server ‹bb-10.1-10715*›
╰─$ grep -Rnie 'GTID_SUPPORT'
sql/wsrep_sst.cc:290:#ifdef GTID_SUPPORT
sql/wsrep_sst.cc:292:#endif /* GTID_SUPPORT */
sql/wsrep_applier.cc:130:#ifdef GTID_SUPPORT
sql/wsrep_applier.cc:141:#endif /* GTID_SUPPORT */
sql/wsrep_applier.cc:309:#ifdef GTID_SUPPORT
sql/wsrep_applier.cc:311:#endif /* GTID_SUPPORT */
sql/wsrep_mysqld.cc:50:#ifdef GTID_SUPPORT
sql/wsrep_mysqld.cc:53:#endif /* GTID_SUPPORT */
sql/wsrep_mysqld.cc:256:#ifdef GTID_SUPPORT
sql/wsrep_mysqld.cc:274:#endif /* GTID_SUPPORT */
sql/wsrep_mysqld.cc:413:#ifdef GTID_SUPPORT
sql/wsrep_mysqld.cc:415:#endif /* GTID_SUPPORT */
sql/wsrep_mysqld.cc:1222:#ifdef GTID_SUPPORT
sql/wsrep_mysqld.cc:1229:#endif /* GTID_SUPPORT */
sql/sql_class.h:4085:#ifdef GTID_SUPPORT
sql/sql_class.h:4087:#endif /* GTID_SUPPORT */
sql/wsrep_mysqld.h:261:#ifdef GTID_SUPPORT
sql/wsrep_mysqld.h:263:#endif /* GTID_SUPPORT */
> diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
> index 33689a9..65751f1 100644
> --- a/sql/wsrep_mysqld.cc
> +++ b/sql/wsrep_mysqld.cc
> @@ -1227,6 +1227,15 @@ int wsrep_to_buf_helper(
> if (!ret && writer.write(>id_ev)) ret= 1;
> }
> #endif /* GTID_SUPPORT */
> + if (wsrep_gtid_mode && thd->variables.gtid_seq_no)
> + {
> + Gtid_log_event gtid_event(thd, thd->variables.gtid_seq_no,
> + thd->variables.gtid_domain_id,
> + true, LOG_EVENT_SUPPRESS_USE_F,
> + true, 0);
> + gtid_event.server_id= thd->variables.server_id;
> + ret= writer.write(>id_event);
> + }
>
> /* if there is prepare query, add event for it */
> if (!ret && thd->wsrep_TOI_pre_query)
--
Regards
Sachin Setiya
Software Engineer at MariaDB