Skip to content
Advertisement

How to troubleshoot ORA-02049 and lock problems in general with Oracle

I am getting ORA-02049 occasionally for some long-running and/or intensive transactions. There is seemingly no pattern to this, but it happens on a simple INSERT.

I have no clue how to get any sort of information out or Oracle, but there has to be a way? A log over locking or atleast a way to see current locks?

Advertisement

Answer

One possible way might be to increase the INIT.ORA parameter for distributed_lock_timeout to a larger value. This would then give you a longer time to observe the v$lock table as the locks would last for longer.

To achieve automation of this, you can either

  • Run an SQL job every 5-10 seconds that logs the values of v$lock or the query that sandos has given above into a table and then analyze it to see which session was causing the lock.

  • Run a STATSPACK or an AWR Report. The sessions that got locked should show up with high elapsed time and hence can be identified.

v$session has 3 more columns blocking_instance, blocking_session, blocking_session_status that can be added to the query above to give a picture of what is getting locked.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement