ORA-60死锁的实验
创建表:
SQL> create table tbl_ora_60 (id number(5),
name varchar2(5)
);
SQL> insert into tbl_ora_60 values(1, 'a');
1 row created.
SQL> insert into tbl_ora_60 values(2, 'b');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from tbl_ora_60;
ID NAME
---------- -----
1 a
2 b
实验开始
Session1:
SQL> update tbl_ora_60 set name='c' where id=1;
1 row updated.
Session2:
SQL> update tbl_ora_60 set name='d' where id=2;
1 row updated.
Session1:
SQL> update tbl_ora_60 set name='e' where id=2;
hang住
Session2:
SQL> update tbl_ora_60 set name='f' where id=1;
hang住
此时,Session1:
SQL> update tbl_ora_60 set name='e' where id=2;
update tbl_ora_60 set name='e' where id=2
*
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
说明:
Session1 Session2
获取id=1的资源锁
获取id=2的资源锁
等待id=2的资源锁
等待id=1的资源锁
id=2的SQL报ORA-60,自动rollback
此时,Session1:
SQL> select * from tbl_ora_60;
ID NAME
---------- -----
1 c
2 b
说明:。
Session2:
SQL> update tbl_ora_60 set name='f' where id=1;
hang住
继续,Session1:
SQL> commit;
Commit complete.
Session2:
SQL> update tbl_ora_60 set name='f' where id=1;
1 row updated.
Session1:
SQL> select * from tbl_ora_60;
ID NAME
---------- -----
1 c
2 b
只有id=1更新成功。
Session2:
SQL> select * from tbl_ora_60;
ID NAME
---------- -----
1 f
2 d
id=1和id=2都更新成功,但未COMMIT。
SQL> commit;
Commit complete.
Session1:
SQL> select * from tbl_ora_60;
ID NAME
---------- -----
1 f
2 d
因Session2执行COMMIT,提交更新,此处显示与Session执行相同。
相关阅读:
ORA-01172、ORA-01151错误处理
ORA-00600 [2662]错误解决
ORA-01078 和 LRM-00109 报错解决方法
ORA-00471 处理方法笔记
ORA-00314,redolog 损坏,或丢失处理方法
ORA-00257 归档日志过大导致无法存储的解决办法