异常日志:
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.
-----------
这是因为在5.6及以上的版本内,开启了enforce_gtid_consistency=true功能导致的,MySQL官方解释说当启用enforce_gtid_consistency功能的时候,MySQL只允许能够保障事务安全,并且能够被日志记录的SQL语句被执行,像create table … select 和 create temporarytable语句,以及同时更新事务表和非事务表的SQL语句或事务都不允许执行。
-----------
那么什么又是 Nontransactional Tables ?
Nontransactional Tables,非事务表,不支持事务的表,也就是使用MyISAM存储引擎的表。
非事务表的特点是不支持回滚,看下面的列子
>create table no_trans(id int) ENGINE=MyiSAM;
>start transaction;
>insert into no_trans values(1);
>select * from no_trans;
+------+
| id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
>rollback;
Query OK, 0 rows affected, 1 warning (0.00 sec)
>show warnings;
+---------+------+---------------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------------+
| Warning | 1196 | Some non-transactional changed tables couldn‘t be rolled back |
+---------+------+---------------------------------------------------------------+
1 row in set (0.00 sec)
>select * from no_trans;
+------+
| id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
与非事务表对应的是事务表,比如使用InnoDB的表,支持回滚操作。
>create table trans(id int);
>start transaction;
>insert into trans values(1);
>select * from trans;
+------+
| id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
>rollback;
Query OK, 0 rows affected (0.00 sec)
>select * from trans;
Empty set (0.00 sec)
max_binlog_stmt_cache_size 该参数影响的是非事务表,如MyISAM,该参数不够时,则提示需要更多的空间。
max_binlog_cache_size 该参数影响的是事务表,如InnoDB,该参数不够时,则提示需要更多的空间。
原文:https://www.cnblogs.com/johnson0608/p/10475078.html