Created
May 18, 2022 06:17
-
-
Save kleontev/eaae4cd880726190f012e66885dde7e4 to your computer and use it in GitHub Desktop.
deadlock demo: only one session is required (since it can have multiple transactions :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> | |
SQL> create table t(id, value) as select 1, 1 from dual; | |
Table created. | |
SQL> | |
SQL> update t set value = value + 1 where id = 1; | |
1 row updated. | |
SQL> | |
SQL> declare | |
2 pragma autonomous_transaction; | |
3 begin | |
4 update t set value = value + 1 where id = 1; | |
5 commit; | |
6 end; | |
7 / | |
declare | |
* | |
ERROR at line 1: | |
ORA-00060: deadlock detected while waiting for resource | |
ORA-06512: at line 4 | |
SQL> | |
SQL> drop table t purge; | |
Table dropped. | |
SQL> | |
SQL> exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set echo on | |
spool single_session_deadlock.log | |
create table t(id, value) as select 1, 1 from dual; | |
update t set value = value + 1 where id = 1; | |
declare | |
pragma autonomous_transaction; | |
begin | |
update t set value = value + 1 where id = 1; | |
commit; | |
end; | |
/ | |
drop table t purge; | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment