Mysql error code 1785 solution after using GTID master-slave replication

Caused by: org.springframework.jdbc.UncategorizedSQLException: 

### Error updating database.  Cause: java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.

### The error may involve com.wm.sj.dao.WmMemberLogDao.insertEntry-Inline

### The error occurred while setting parameters

### SQL: INSERT INTO wm_member_log (id,operate_type,member_id,erp_user,created,modified,remark)    VALUES (?,?,?,?,?,?,?)

### Cause: java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.

; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1785]; When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.; nested exception is java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.

This means that when replication mode for GTIDs is enabled, updating transactional and non-transactional tables in the same transaction will result in multiple GTIDs being assigned to the same transaction. Therefore, operations such as create and update cannot be completed. The following is the explanation from the official document.

 http://dev.mysql.com/doc/refman/5.6/en/replication-options-gtids.html

 CREATE TABLE ... SELECT statements

 CREATE TEMPORARY TABLE statements inside transactions

Transactions or statements that update both transactional and nontransactional tables.

Solution:

Change the error table error_table storage engine to innodb.

ALTER TABLE error_table ENGINE=InnoDB;

Check out the modified results:

SHOW CREATE TABLE error_table\G;

The msyql service needs to be restarted after modification.
The following errors are logged

Guess you like

Origin blog.csdn.net/m1195900241/article/details/132205759