[MDEV-20715] Implement system variable to disallow local GTIDs in Galera Created: 2019-10-01  Updated: 2021-04-19  Resolved: 2021-03-02

Status: Closed
Project: MariaDB Server
Component/s: Galera, Replication, wsrep
Fix Version/s: 10.6.0

Type: Task Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Jan Lindström (Inactive)
Resolution: Fixed Votes: 2
Labels: None

Issue Links:
Duplicate
Relates
relates to MDEV-20720 Galera: Replicate MariaDB GTID to oth... Closed
relates to MDEV-22905 Support DO_DOMAIN_IDS and IGNORE_DOMA... Closed
relates to MDEV-25024 Document wsrep_mode to disallow local... Closed
relates to MXS-2580 Clarify requirements of binlog router... Closed

 Description   

It is possible to use Galera Cluster with replication. For example:

https://mariadb.com/kb/en/library/documentation/replication/galera-cluster/using-mariadb-replication-with-mariadb-galera-cluster/configuring-mariadb-replication-between-two-mariadb-galera-clusters/

https://mariadb.com/kb/en/library/documentation/replication/galera-cluster/using-mariadb-replication-with-mariadb-galera-cluster/using-mariadb-gtids-with-mariadb-galera-cluster/

https://mariadb.com/kb/en/library/documentation/replication/galera-cluster/using-mariadb-replication-with-mariadb-galera-cluster/using-mariadb-replication-with-mariadb-galera-cluster-using-mariadb-replica/

However, if the slave of the Galera Cluster needs to fail over to a new master node, then that can be complicated by the fact that the different nodes may have different GTID positions due to local transactions.

Nodes can have GTIDs for local transactions in the following scenarios:

  • A DDL statement is executed with wsrep_OSU_method=RSU set.
  • A DML statement writes to a non-InnoDB table.
  • A DML statement writes to an InnoDB table with wsrep_on=OFF set.

We may want to come up with a way to disallow any statements that would cause local GTIDs in Galera Cluster.

For example, we could implement a new system variable called wsrep_disallow_local_gtids. If a user tries to execute a statement that would cause a local GTID, then it could trigger an error. For example:

SET GLOBAL wsrep_disallow_local_gtids=ON;
Query OK, 0 rows affected (0.000 sec)
 
SET SESSION wsrep_OSU_method='RSU';
Query OK, 0 rows affected (0.000 sec)
 
ALTER TABLE tab FORCE;
ERROR X (Y): You can't execute statements that would generate local GTIDs when 
  wsrep_disallow_local_gtids is set. Try disabling binary logging with "SET sql_log_bin=0" 
  to execute this statement.

Or:

SET GLOBAL wsrep_disallow_local_gtids=ON;
Query OK, 0 rows affected (0.000 sec)
 
SET SESSION wsrep_on=OFF;
Query OK, 0 rows affected (0.000 sec)
 
INSERT INTO innodb_tab VALUES (1, 'str');
ERROR X (Y): You can't execute statements that would generate local GTIDs when 
  wsrep_disallow_local_gtids is set. Try disabling binary logging with "SET sql_log_bin=0" 
  to execute this statement.

But users could still work around this by disabling binary logging. For example:

SET GLOBAL wsrep_disallow_local_gtids=ON;
Query OK, 0 rows affected (0.000 sec)
 
SET SESSION wsrep_on=OFF;
Query OK, 0 rows affected (0.000 sec)
 
SET SESSION sql_log_bin=0;
Query OK, 0 rows affected (0.000 sec)
 
INSERT INTO innodb_tab VALUES (1, 'str');
Query OK, 1 rows affected (0.000 sec)



 Comments   
Comment by Jan Lindström (Inactive) [ 2021-03-01 ]

https://github.com/MariaDB/server/commit/ebb2db5912ebb9b4e3ef230f15ae65529ff30be4

Comment by Jan Lindström (Inactive) [ 2021-03-02 ]

Added a new wsrep_mode feature DISALLOW_LOCAL_GTID for this. Nodes can have GTIDs for local transactions in the following scenarios:

  • A DDL statement is executed with wsrep_OSU_method=RSU set.
  • A DML statement writes to a non-InnoDB table.
  • A DML statement writes to an InnoDB table with wsrep_on=OFF set.

If user has set wsrep_mode=DISALLOW_LOCAL_GTID these operations produce a error ERROR HY000: Galera replication not supported.

Generated at Thu Feb 08 09:01:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.