begin;
insert into t select 1; savepoint t1; insert into t select 2; savepoint t2; release savepoint t1; insert into t select 2; ERROR 1062(23000):Duplicate entry'2'for key'PRIMARY' rollback to savepoint t2; select * from t; rollback;
可以在 information_schema.innodb_trx 这个表中查询长事务
# 查找持续时间超过 60s 的事务
select * from information_schema.innodb_trx where TIME_TO_SEC(timediff(now(),trx_started))>60;