Query to check deadlock status of table in postgres

I want to check whether deadlock cleared or not in system tables of Postgres and ORACLE.

Kindly suggest me on how to check the deadlock status .

2

1 Answer

Deadlocks don't hang around, as soon as Postgres or Oracle finds a deadlock it will abort one of the transactions. This is because a deadlock, by its very nature, won't progress without intervention.

What you can do is look at what normal locks exist in the system and how long they've been there.

Locks that are held for a long time might indicate slow running transactions, or code that isn't committing at the correct place etc.

Long held locks also increase the likelihood that a deadlock will occur in the future.

Postgres

You can do this via the pg_locks view.

The Postgresql wiki has a page about looking at locks at

And the pg_locks view is described at

Oracle

Oracle also provides views to show the current locks, but they're a bit more complex to use.

An intro is available at

With reference at

In both cases though you'll need to spend a bit of time identifying what you're actually after as locks typically aren't held on the whole table at once, so its likely that different parts of the table will have locks on them at the same time by different transactions. Also its is not just tables that will show up in these views.

Similarly the different lock types (shared, exclusive, etc.) will block different types of concurrent activity.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like