Said GTID - limit GTID-based replication

  • The same transaction (statements), it can not change transactions and involve both non-transactional data tables, which will lead to a corresponding number GTID transaction, a violation of the principle of affairs-one correspondence with the GTID.


[[email protected]][db1]> show create table t2 \G

*************************** 1. row ***************************

       Table: t2

Create Table: CREATE TABLE `t2` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  PRIMARY KEY (`id`)

) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4

1 row in set (0.00 sec)


[[email protected]][db1]> start transaction;

Query OK, 0 rows affected (0.00 sec)


[[email protected]][db1]> insert into t1 select null;

Query OK, 1 row affected (0.00 sec)

Records: 1  Duplicates: 0  Warnings: 0


[[email protected]][db1]> insert into t2 select null;

ERROR 1785 (HY000): Statement violates GTID consistency: Updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.

[[email protected]][db1]> commit;

Query OK, 0 rows affected (0.01 sec)



  • You can not use CREATE TABLE ... SELECT statement.


[[email protected]][db1]> create table t2 select * from t2;

ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... SELECT.




  • In the transaction, stored procedures, functions and triggers, you can not use the CREATE TEMPORARY TABLE, and DROP TEMPORARY TABLE statement.


[[email protected]][db1]> start transaction;

Query OK, 0 rows affected (0.00 sec)


[[email protected]][db1]> create temporary table t4 (id int auto_increment primary key);

ERROR 1787 (HY000): Statement violates GTID consistency: CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE can only be executed outside transactional context.  These statements are also not allowed in a function or trigger because functions and triggers are also considered to be multi-statement transactions.

[[email protected]][db1]> rollback;

Query OK, 0 rows affected (0.00 sec)


[[email protected]][db1]> create temporary table t4 (id int auto_increment primary key);

Query OK, 0 rows affected (0.01 sec)


[[email protected]][db1]> desc t4;

+-------+---------+------+-----+---------+----------------+

| Field | Type    | Null | Key | Default | Extra          |

+-------+---------+------+-----+---------+----------------+

| id    | int(11) | NO   | PRI | NULL    | auto_increment |

+-------+---------+------+-----+---------+----------------+

1 row in set (0.00 sec)


[[email protected]][db1]> drop temporary table t4;

Query OK, 0 rows affected (0.00 sec)


[[email protected]][db1]> desc t4;

ERROR 1146 (42S02): Table 'db1.t4' doesn't exist



  • Open --enforce-gtid-consistency parameters, block the execution statement violates the principle GTID-based replication.



  • Skip execution of transactions, the parameter sql_slave_skip_counter no longer works, it requires use of the following transaction injection empty skip.


SET GTID_NEXT='aaa-bbb-ccc-ddd:N';


BEGIN;

COMMIT;


SET GTID_NEXT='AUTOMATIC';



CHANGE MASTER TO statement IGNORE_SERVER_IDS not work, has been played back transactions will be automatically skipped.



  • When using mysqldump export data in the open GTID example, the backup file will be provided @@ SESSION.SQL_LOG_BIN = 0, when import data using the backup file to the destination instance is not recorded binary log.



  • When using mysql_upgrade on an instance of open GTID place upgrade MySQL version, or write binary log (which is the default behavior mysql_upgrade, did not open --write-binlog).


Guess you like

Origin blog.51cto.com/coveringindex/2426453