DBAtlas · Database operations atlas

1785: Statement violates GTID consistency

MySQL

What 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.

Open in DBAtlas →

More from this engine