Investigate #Oracle #deadlocks

By | May 10, 2018

Sometimes we may end up having some application resources competing for the same resource on our Oracle database. This is usually the case when some exclusive resource must be allocated or updated as in the case of database based locking mechanisms.

If there are code issues we may end up in a deadlock situation when application resources are locked in a cycle of requiring exclusivity over some resource.

In this case sessions in Oracle will get blocked by other sessions.

To be able to investigate the issue at the application level it is very useful to understand what application call is blocked and who is blocking it.

Detect block sessions and who is the owner
In case of a deadlock we can find out, by running as sysdba the following query, who is the blocked session , who is the blocker session and which are the owners of the sessions:

In case no deadlock is present the above query will return nothing.

In case one or more deadlocks are present the return rows will contain all the info we need to see who is waiting for who.

Further on we can investigate using the blocker session ID to see why that session is not terminating and who is the offending SQL query.

Contribute to this site maintenance !

This is a self hosted site, on own hardware and Internet connection. The old, down to earth way 🙂. If you think that you found something useful here please contribute. Choose the form below (default 1 EUR) or donate using Bitcoin (default 0.0001 BTC) using the QR code. Thank you !

€1.00

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.