1688
MySQLERRORCommonReplicationHIGH confidence
Statement is unsafe because it is being split into multiple statements while a GTID is assigned
Production Risk
High — replication can break if GTID consistency is violated.
What this means
A statement that MySQL must split into multiple binary log events was executed while a GTID was already assigned, which violates GTID consistency because a single GTID must map to exactly one logical transaction.
Why it happens
- 1Executing a CREATE TABLE ... SELECT or similar splittable statement in gtid_mode=ON.
- 2Session has an explicit GTID_NEXT assigned and the statement generates multiple binlog events.
How to reproduce
trigger — this will error
trigger — this will error
SET GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; CREATE TABLE t2 SELECT * FROM t1;
expected output
ERROR 1688 (HY000): Statement is unsafe because it is being split into multiple statements while an explicit GTID is assigned.
Fix
Separate the DDL and DML into distinct transactions
Separate the DDL and DML into distinct transactions
CREATE TABLE t2 LIKE t1; INSERT INTO t2 SELECT * FROM t1;
Why this works
Each statement is now a separate transaction, each receiving its own GTID.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1688 ER_GTID_UNSAFE_BINLOG_SPLITTABLE_STATEMENT_AND_ASSIGNED_GTID
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev