Home  >  Article  >  Database  >  mysql事务rollback失效_MySQL

mysql事务rollback失效_MySQL

WBOY
WBOYOriginal
2016-06-01 13:02:412217browse

最近支付业务发生了一件怪事,在一个事务 失败后,调用rollback,发现只rollback 了最后一条sql。

开发查了很久,发现是网络抖动,造成第一次创建链接的 begin 丢掉了,后面再重连后就变成autocommit了,这样就造成rollback的时候前面的sql 全都没有rollback。

tudou@b2c.xiaomi.com

只能是在 begin 的时候加一个变量将应用服务器的时间戳打到mysql 服务器上,后面所有操作都去读下这个时间戳,和应用服务器上的时间戳一致,就ok,否则就重做。效率差了很多,但是保证了事务。

tudou@b2c.xiaomi.com

其他同学有什么好办法么?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn