-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotes
21 lines (19 loc) · 1.47 KB
/
Notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
select @@global.tx_isolation,@@tx_isolation;查看全局隔离级别和会话隔离级别
Read Committed级别出现两次查询结果不同:
1.事务A开启,查询id=1的记录
2.事务B开启,修改id=1的记录
3.事务A查询id=1的记录已经改变
Repeatable Read(可重读):一直读的都是开启事务之前的数据。
SET [SESSION | GLOBAL] TRANSACTION ISOLATION LEVEL {READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE}
mysql> set global transaction isolation level read committed; //全局的
mysql> set session transaction isolation level read committed; //当前会话
Error:
### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may involve com.homo.mapper.UsersMapper.updateByPrimaryKeySelective-Inline
### The error occurred while setting parameters
### SQL: update users SET name = ? where id = ?
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
; ]; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
Spring事务传播级别实现:通过不同的conn对象连接处理。有超时风险。
conn1开启事务,更新某一行,取得行锁
conn2开启事务更新同一行会抛超时异常。