Error
Error Code:
4112
MySQL Error 4112: GIPK Disallowed in SBR
Description
This error occurs when MySQL attempts to generate an invisible primary key (GIPK) for a new table created using `CREATE TABLE ... SELECT` while the `binlog_format` is set to `STATEMENT`. This combination is disallowed because the order of rows returned by `SELECT` cannot be guaranteed across source and replica, leading to potential data inconsistency for the GIPK values during replication.
Error Message
Generating an invisible primary key for a table created using CREATE TABLE ... SELECT ... is disallowed when binlog_format=STATEMENT. It cannot be guaranteed that the SELECT retrieves rows in the same order on source and replica. Therefore, it cannot be guaranteed that the value generated for the generated implicit primary key column will be the same on source and replica for all rows. Use binlog_format=ROW or MIXED to execute this statement.
Known Causes
4 known causesUsing CREATE TABLE ... SELECT
The `CREATE TABLE ... SELECT` statement is used to create a new table and populate it with data from a `SELECT` query.
Automatic Invisible Primary Key (GIPK)
MySQL is configured to automatically generate an invisible primary key for tables that do not explicitly define one, to ensure every table has a primary key.
binlog_format=STATEMENT
The binary logging format is set to `STATEMENT`, which logs SQL statements directly, making replication sensitive to execution order.
Non-deterministic SELECT Order
Without an `ORDER BY` clause, the order of rows returned by a `SELECT` statement is not guaranteed to be consistent, which can cause replication issues with GIPK.
Solutions
Coming SoonGeneral Troubleshooting Tips
- Check the error message carefully for specific details
- Review recent changes that might have caused the error
- Search for the exact error code in the official documentation
- Check log files for additional context
- Try restarting the application or service