• mysql Statement violates GTID consistency 的坑


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

    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,问题搞定

    事实上后面我又试了mysql5.7以上的版本,同样将引擎修改为MyISAM,执行操作,显示执行成功。到这儿我真的不知道究竟什么情况了,但确实是我让运维的同事将我的表的引擎修改为InnoDB就执行成功了。所以如果你也遇到同样的问题,不防检查一下表的引擎,修改一下试试

  • 相关阅读:
    Linux 发展历史
    购物车0612版登陆与购物功能
    Linux 基本命令
    MySQL练习
    购物车登陆购物版
    MySQL阅读目录
    输入打印之佛祖辟邪
    mysql存储引擎
    函数对象、函数嵌套、名称空间与作用域、装饰器
    【计算机网络】哈尔滨工业大学MOOC-计算机网络 第2周 计算机网络概述(下) 作业2
  • 原文地址:https://www.cnblogs.com/canmeng-cn/p/5969188.html
Copyright © 2020-2023  润新知