允许 enforce-gtid-consistency 可能引发的错误
21:43:04[test](;)> CREATE TABLE test (c1 BIGINT UNSIGNED NOT NULL); Query OK, 0 rows affected (0.11 sec) 21:44:22[test](;)> insert into test values(0); Query OK, 1 row affected (0.11 sec) 21:44:26[test](;)> create table test1 select c1 -1 as c2 from test; ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... SELECT.
原因是在binlog为row模式下,create table .... select这类语句在binlog中相当于两个event,一个是建表语句,一个是insert,当在从库上执行到insert时,某些情景导致insert中断,那么就会导致主从数据不一致,因为create时无事务的,导致在从上重现时无法原子性执行。