Friday, 14 April 2017

Oracle Deadlocks


Deadlock in oracle
In a database, when a session (e.g. ora) wants a resource held by another session (e.g. data), but that session (data) also wants a resource which is held by the first session (ora). There can be more than 2 sessions involved also but idea will be the same.
Actually, Deadlocks prevent some transactions from continuing to work.
For example:
Suppose, ORA-DATA holds lock A and requests lock B
And SKU holds lock B and requests lock A.
There are two types of deadlocks:
i.e. a potential deadlock or an actual deadlock.
Potential deadlock: It does not occur necessarily in a given run but it can occur in any execution of program which depending on the scheduling of the thread and timing of locks requests by the threads.
Actual deadlock: It is one of deadlock which occurs during the execution of a program. Because of this deadlock processes hang, it may hang either whole processes or one process.

 

Deadlock Avoidance

Deadlock can be reduce or avoid by avoid locking contention. We should also make sure that all programs access the data in orders. Sometimes if database application design is not proper that may also cause this issue, so database design should be proper way.

From Alert Log:
Mon Apr 10 19:40:59 2017
ORA-00060: Deadlock detected. More info in file /opt/SKUdb/9.2.0/admin/SKU/udump/ora-data_ora_172589.trc.
Mon Apr 10 20:07:21 2017

From Trace File:
DEADLOCK DETECTED ( ORA-00060 )
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TX-008f0003-0008de0d       190     286     X             25     585           X
TX-00fc0012-0008bc4c        25     585     X            190     286           X
session 286: DID 0001-00B4-0000116F     session 585: DID 0001-001A-00000A4E
session 585: DID 0001-001A-00000A4E     session 286: DID 0001-00B4-0000116F
Rows waited on:
Session 585: obj - rowid = 0015E796 - AAnDcRALTAAByX3AAp
  (dictionary objn - 1435542, file - 723, block - 468471, slot - 42)
Session 486: obj - rowid = 0015E78F - AAnDZGAJfAACPikAAz
  (dictionary objn - 1435535, file - 607, block - 587940, slot - 52)
Information on the OTHER waiting sessions:
Session 585:
  pid=11 serial=1943 audsid=1423567819 user: 192/APPS
  O/S info: user: kmisadm, term: , ospid: 253647, machine: ora-data
            program:
  client info: 1920                                                   0
  application name: ora-data.blogspot.com, hash value=1925436782
  action name: Concurrent Request, hash value=1925436782
  Current SQL Statement:

Checking:
To check the deadlock details, Please find the below points:
SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
ORA-DATA         OPEN

SQL> set lines 32
SQL> SELECT DECODE(request,0,'Holder: ','Waiter: ')||sid sess,
  id1, id2, lmode, request, type
 FROM V$LOCK
WHERE (id1, id2, type) IN
 (SELECT id1, id2, type FROM V$LOCK WHERE request>0)
ORDER BY id1, request;

no rows selected

SQL> /

no rows selected

SQL> /
In above command, there is no row selected, it means there is no locking or deadlock at present. It may clear automatically. So, no need to worry about this.
And if we have still active session or getting output from above query then there is simple work-around or solution as:
Identify the particular user and session details which causing the blocking and then find the details about the session as what session is running or doing then contact to particular user and ask for killing the session if nothing important session is working from below command:
SQL>sqlplus ‘/as sysdba’
SQL>ALTER SYSTEM KILL SESSION ‘SID,SERIAL#’;
SQL>
Then again check the details from above command for locks or waits.
Some more useful link:
Hope above information useful and helpful. Please let us know for any concerns or suggestions either in comment box or contact us @https://ora-data.blogspot.in/

Thanks,

17 comments:

  1. Nice post. I learn something new andd challenging on weebsites I stumbleupon on a daily basis.
    It's always interesting to read through coontent from other writers annd use a little something from other web sites.

    ReplyDelete
    Replies

    1. Dear User,

      Thank you very much for your feedback.

      Regards,
      ora-data Team

      Delete
  2. Just want to say your article is as astonishing. The
    clarity in your post is just spectacular and that i can suppose you are a
    professional in this subject. Fine together with your permission let me to seize your
    RSS feed to keep up to date with imminent post. Thanks 1,000,000 and please keep up the rewarding work.

    ReplyDelete
  3. Instructions to Solve Oracle Deadlock Issue through Remote DBA Services
    The Oracle Deadlock issue which is likewise called ORA-00060 which signifies "Stop identified while sitting tight for asset" the primary driver for this issue is exchange halted each other while sitting tight for assets. To determine this issue you need to tune the application, include INITRANS or utilize littler squares with less information. In the event that as yet confronting a similar issue at that point contact to Online Oracle DB Support or Oracle Database Solution.
    For More Info: https://cognegicsystems.com
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete
  4. You are my intake, I have few blogs and very sporadically run out from brand :).

    ReplyDelete
    Replies

    1. Dear User,

      Thank you very much for your Great feedback. Its really mean for for us. :)

      Regards,
      ora-data Team

      Delete
  5. Appreciating the dedication you put into your website and detailed information you provide.
    It's nice to coome across a blog every once in a
    wjile that isn't the same out of date rehashed information. Fantastic read!
    I've bookmarked your site and I'm adding your RSS feeds to my Google account.

    ReplyDelete
  6. Great post. I am dealing with some of these issues as well..

    ReplyDelete
    Replies

    1. Dear User,

      Thank you very much for your Great feedback. :)

      Regards,
      ora-data Team

      Delete
  7. Good information. Lucky me I came across your site by chance (stumbleupon).
    I have book marked it for later!

    ReplyDelete
    Replies

    1. Dear User,

      Thank you very much for your feedback. :)

      Regards,
      ora-data Team

      Delete

  8. Dear User,

    Thank you for your feedback. Could you please let us know which browser you are using and either in mobile or desktop. Here for us everything is working fine.

    Also, sometimes it may be cause of slow internet.

    Regards,
    ora-data Team

    ReplyDelete

  9. Dear User,

    Thank you very much for your feedback. :)

    Regards,
    ora-data Team

    ReplyDelete

  10. Dear User,

    Thank for your feedback.
    Sure, we will try our best to make easy, please check our other posts.

    Regards,
    ora-data Team

    ReplyDelete
  11. Hi! Someone in my Myspace group shared this website
    with us so I came to take a look. I'm definitely loving the information. I'm
    book-marking and will be tweeting this to my followers!
    Exceptional blog and fantastic style and design.

    ReplyDelete

  12. Dear User,

    Thank you very much for your great feedback...
    Please subscribe us for latest updates...

    Regards,
    ora-data Team

    ReplyDelete
  13. Hi! This is myy first comment here so I just wanted to
    give a quick shout out and say I truly enjoy reading through your
    articles. Can you suuggest any other blogs/websites/forums that go over the same
    subjects? Thank you so much!

    ReplyDelete

Thank you for your comments and suggestions. It's good to talk you.