Maybe this is PLSQL Developer's fault, maybe it's Oracle's fault, or maybe I'm doing something really stupid, but I can make PLSQL Developer hang by doing the following:
In a command window, run the following:
Now open a SQL window, and run:
Now open another SQL window, and run:
And in that window, click the little lock icon, remove the row from the table and click the green checkmark (note: I have "AutoCommit posted records" checked). PLSQL Developer now hangs.
Looking at the Sessions window, each SQL window has its own session, so it makes sense that the commit can't happen until the "for update" on DEADLOCK_CHILD is released. The problem is that all of PLSQL Developer is unresponsive, so I can't switch to that other SQL window to commit/rollback.
Note: fixing this is not an immediate priority to me. This is not something I do every day
In a command window, run the following:
Code:
-- Create table
create table DEADLOCK_PARENT
(
parent_id number
);
-- Create/Recreate primary, unique and foreign key constraints
alter table DEADLOCK_PARENT
add constraint PK_DEADLOCK_PARENT primary key (PARENT_ID);
-- Create table
create table DEADLOCK_CHILD
(
child_id number,
parent_id number
);
-- Create/Recreate primary, unique and foreign key constraints
alter table DEADLOCK_CHILD
add constraint PK_DEADLOCK_CHILD primary key (CHILD_ID);
alter table DEADLOCK_CHILD
add constraint FK_DEADLOCK_CHILD foreign key (PARENT_ID)
references deadlock_parent (PARENT_ID) on delete cascade;
insert into deadlock_parent values (1);
insert into deadlock_child values (1, 1);
commit;
Code:
select * from DEADLOCK_CHILD for update;
Code:
select * from DEADLOCK_PARENT for update;
Looking at the Sessions window, each SQL window has its own session, so it makes sense that the commit can't happen until the "for update" on DEADLOCK_CHILD is released. The problem is that all of PLSQL Developer is unresponsive, so I can't switch to that other SQL window to commit/rollback.
Note: fixing this is not an immediate priority to me. This is not something I do every day
