1785: Statement violates GTID consistency
MySQLWhat does it mean?
With GTID (Global Transaction Identifier) based replication enabled, the executed statement violates GTID consistency rules. GTID mode does not allow certain statement types that cannot be safely assigned to a single GTID.
Why does it happen?
1785 (ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE) occurs specifically when non-transactional (e.g. MyISAM) tables are updated in the same transaction as transactional (InnoDB) tables, or in a multi-statement transaction without autocommit. In older versions, CREATE TABLE ... SELECT (before 8.0.21; allowed in 8.0.21+ for engines supporting atomic DDL) and CREATE/DROP TEMPORARY TABLE inside a transaction (before 8.0.13; allowed in 8.0.13+ when binlog_format is ROW/MIXED) also violate GTID consistency (these are reported with separate error codes). They are rejected when enforce_gtid_consistency=ON.
How to fix it
Do not mix non-transactional engine tables with transactional tables in the same transaction; update MyISAM tables with single autocommit statements or move all tables to InnoDB: ALTER TABLE my_table ENGINE=InnoDB; In older versions (before 8.0.21), split CREATE TABLE ... SELECT into two steps (CREATE TABLE, then INSERT ... SELECT); before 8.0.13, create and drop temporary tables outside an explicit transaction.
More from this engine
- 1267Illegal mix of collations
- 1030Got error N from storage engine
- 1197Multi-statement transaction required more than 'max_binlog_cache_size'
- 3024Query execution was interrupted, maximum statement execution time exceeded
- 1298Unknown or incorrect time zone
- 1418Function has none of DETERMINISTIC, NO SQL, or READS SQL DATA (binary logging enabled)
- 1231Variable can't be set to the value of ...