mysql Statement violates GTID consistency 的坑

时间:2016-10-17 14:10:42   收藏:0   阅读:7641

今天项目迁移,重新换了一个数据库版本,然后问题来了,原本运行正常的程序迁移过来之后就是不能正常运行,后台报错如下:

update tbl_user_info set -- 强制下架 mv_count = mv_count-1, update_time=now() where user_id = ?; update tbl_user_info a,tbl_mv_like b set a.enjoy_num = a.enjoy_num -1, a.update_time = now() where b.mvlikeId = ? and b.userId =a.user_id and b.userId != ? and b.isLIke = 1 and b.state = 0
### Cause: java.sql.SQLException: Statement violates GTID consistency: 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]; Statement violates GTID consistency: 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: Statement violates GTID consistency: 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.

网上查了一下 Statement violates GTID consistency这个,然后看到这个网页https://dev.mysql.com/doc/refman/5.6/en/replication-options-gtids.html,一开始还以为是数据库模式的问题,后面看了下数据库表,才知道原来是运维人员在新的数据库上把我的数据库表的模式设置成了MyISAM这个模式,然后去数据库show engines了一下,技术分享

可以看到,这个模式是不支持事物的,将它修改为InnoDB,问题搞定

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!