Search notes:

ORA-00060: deadlock detected while waiting for resource

The error ORA-00060: deadlock detected while waiting for resource is thrown if two sessions (or possibly more accurately: two transactions) wait for a resource that the other session (transaction) has already aquired.
Jonathan Lewis has found that the session that waited the longest gets the ORA-00060.

Demonstration

Create some demonstration values:
create table tq84_00600_deadlock (
   id   integer  primary key,
   val  varchar2(20)
);

begin
   insert into tq84_00600_deadlock values (42, 'A');
   insert into tq84_00600_deadlock values (99, 'B');
   commit;
end;
/
Session 1 updates a record but does not commit the transaction:
update tq84_00600_deadlock set val = 'C' where id = 42;
Session 2 updates another record, also without commiting the transaction:
update tq84_00600_deadlock set val = 'X' where id = 99;
Session 2 tries to update the record which is already updated by another session (i. e. session 1). Because the other session locks the records, session 2 is blocked with the following update statement:
update tq84_00600_deadlock set val = 'Y' where id = 42;
Sesion 1 tries to update the record which is already updated by session 2:
update tq84_00600_deadlock set val = 'D' where id = 99;
This update staement leads to a situation where both would be blocked. Oracle handles this by raising ORA-00060: deadlock detected while waiting for resource in one of the two sessions.
Cleaning up:
drop   table tq84_00600_deadlock;

See also

Metalink note 62365.1
Other Oracle error messages

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759473983, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/errors/ORA-00060_deadlock-detected-while-waiting-for-resource/index(81): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78