有个小服务用Mysql做存储,有个表对insert做了如下触发器:
CREATE TRIGGER `t_afterinsert_on_se_buf` AFTER INSERT ON `se_buf` FOR EACH ROW BEGIN insert se(`date`,`shift_id`,`device_id`,`tingji_secs`,`kaiji_secs`,`lixian_secs`,`kailu_secs`,`kailuzuoguan_secs`,`storetime`) value(new.`date`, (select `id` from `shift` where `shift_no` = new.shift_code), (select `id` from `device` where `code` = new.device_code), new.tingji_secs,new.kaiji_secs,new.lixian_secs,new.kailu_secs,new.kailuzuoguan_secs,new.storetime); END;
服务运行数日后,查看日志后发现有以下异常:
java.sql.SQLException: Could not retrieve transation read-only status server
解决过程如下:
一、事务性方面
数据库采用了Mysql 5.7 ,存储引擎为innodb,事务隔离等级为:
修改my.cnf,增加:
transaction_isolation = READ-COMMITTED
切换为READ-COMMITTED等级。
问题分析:
READ COMMITTED别的事物在未提交事务前,别的事务时不能访问这个事务。
REPEATABLE-READ事务隔离等级是在读事务提交前,别的事务可以更改数据,但不可以插入数据
-
-
参考文献
http://www.cnblogs.com/jeffen/p/6005410.html