Blocking session Locks

Hi,
Need some assistance...!
For the last few weeks i was getting the blocking session alerts and when i checked out for what the blocking session is doing, i found some select or insert or pl/sql line of code is getting executed. but the thing is i have observed the blocking is done on the same table each time.
Any suggestions how i can proceed further ? why the lock is getting on the similar table.
Regards,
Sunila

About code examination, you could check the detailed SQL statements:
- INSERT should only block if another INSERT is run on the same table with the same primary key and in this case the second INSERT statement will fail due to duplicate key.
- SELECT can only block if SELECT with FOR UPDATE clause is used and in this case all rows returned by the SELECT (for a single table SELECT) are locked. SELECT without FOR UPDATE clause does not block.
If not already done, see How Oracle locks data.

Similar Messages

  • FOR UPDATE cursor is causing Blocking/ Dead Locking issues

    Hi,
    I am facing one of the complex issues regarding blocking / dead locking issues. Please find below the details and help / suggest me the best approach to ahead with that.
    Its core Investment Banking Domain, in Our Day to day Business we are using many transaction table for processing trades and placing the order. In specific there are two main transaction table
    1)     Transaction table 1
    2)     Transaction table 2
    These both the tables are having huge amount of data. In one of our application to maintain data integrity (During this process we do not want other users to change these rows), we have placed SELECT …………….. FOR UPDATE CURSOR on these two table and we have locked all the rows during the process. And we have batch jobs (shell scripts ) , calling this procedure , we will be running 9 times per day 1 hrs each start at 7:15AM in the morn finish it up in the eve 5PM . Let’s say. The reason we run the same procedure multiple times is, our business wants to know the voucher before its finalized. Because there is a possibility that order can be placed and will be updated/cancelled several times in a single day. So at the end of the day , we will be sending the finalized update to our client.
    20 07 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 08 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 09 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 10 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 11 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 12 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 13 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 14 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 15 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 16 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    20 17 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
    Current Program will look like:
    App_Prc_1
    BEGIN
    /***** taking the order details (source) and will be populate into the table ****/
    CURSOR Cursor_Upload IS
    SELECT col1, col2 … FROM Transaction table1 t 1, Source table 1 s
    WHERE t1.id_no = t2.id_no
    AND t1.id_flag = ‘N’
    FOR UPDATE OF t1.id_flag;
    /************* used for inserting the another entry , if theres any updates happened on the source table , for the records inserted using 1st cursor. **************/
    CURSOR cursor_update IS
    SELECT col1, col2 … FROM transaction table2 t2 , transaction table t1
    WHERE t1.id_no = t2.id_no
    AND t1.id_flag = ‘Y’
    AND t1.DML_ACTION = ‘U’,’D’ -- will retrieve the records which are updated and deleted recently for the inserted records in transaction table 1 for that particular INSERT..
    FOR UPDATE OF t1.id_no,t1.id_flag;
    BLOCK 1
    BEGIN
    FOR v_upload IN Cursor_Upload;
    LOOP
    INSERT INTO transaction table2 ( id_no , dml_action , …. ) VALUES (v_upload.id_no , ‘I’ , … ) RETURNING v_upload.id_no INTO v_no -- I specify for INSERT
    /********* Updating the Flag in the source table after the population ( N into Y ) N  order is not placed yet , Y  order is processed first time )
    UPDATE transaction table1
    SET id_FLAG = ‘Y’
    WHERE id_no = v_no;
    END LOOP;
    EXCEPTION WHEN OTHER THEN
    DBMS_OUTPUT.PUT_LINE( );
    END ;
    BLOCK 2
    BEGIN -- block 2 starts
    FOR v_update IN Cursor_Update;
    LOOP;
    INSERT INTO transaction table2 ( id_no ,id_prev_no, dml_action , …. ) VALUES (v_id_seq_no, v_upload.id_no ,, … ) RETURNING v_upload.id_no INTO v_no
    UPDATE transaction table1
    SET id_FLAG = ‘Y’
    WHERE id_no = v_no;
    END LOOP;
    EXCEPTION WHEN OTHER THEN
    DBMS_OUTPUT.PUT_LINE( );
    END; -- block2 end
    END app_proc; -- Main block end
    Sample output in Transaction table1 :
    Id_no | Tax_amt | re_emburse_amt | Activ_DT | Id_Flag | DML_ACTION
    01 1,835 4300 12/JUN/2009 N I ( these DML Action will be triggered when ever if theres in any DML operation occurs in this table )
    02 1,675 3300 12/JUN/2009 Y U
    03 4475 6500 12/JUN/2009 N D
    Sample output in Transaction table2 :
    Id_no | Prev_id_no Tax_amt | re_emburse_amt | Activ_DT
    001 01 1,835 4300 12/JUN/2009 11:34 AM ( 2nd cursor will populate this value , bcoz there s an update happened for the below records , this is 2nd voucher
    01 0 1,235 6300 12/JUN/2009 09:15 AM ( 1st cursor will populate this record when job run first time )
    02 0 1,675 3300 12/JUN/2009 8:15AM
    003 03 4475 6500 12/JUN/2009 11:30 AM
    03 0 1,235 4300 12/JUN/2009 10:30 AM
    Now the issues is :
    When these Process runs, our other application jobs failing, because it also uses these main 2 tranaction table. So dead lock is detecting in these applications.
    Solutin Needed :
    Can anyone suggest me , like how can rectify this blocking /Locking / Dead lock issues. I wants my other application also will use this tables during these process.
    Regards,
    Maran

    hmmm.... this leads to a warning:
    SQL> ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL';
    Session altered.
    CREATE OR REPLACE PROCEDURE MYPROCEDURE
    AS
       MYCOL VARCHAR(10);
    BEGIN
       SELECT col2
       INTO MYCOL
       FROM MYTABLE
       WHERE col1 = 'ORACLE';
    EXCEPTION
       WHEN PIERRE THEN
          NULL;
    END;
    SP2-0804: Procedure created with compilation warnings
    SQL> show errors
    Errors for PROCEDURE MYPROCEDURE:
    LINE/COL                                                                          ERROR
         12/9        PLW-06009: procedure “MYPROCEDURE” PIERRE handler does not end in RAISE or RAISE_APPLICATION_ERROR
         :)

  • Blocking sessions during MGP compose

    We keep getting the MGP compose process blocked by inactive sessions
    We raised a SR with Oracle and they suggested adding the instance parameter DO_APPLY_BFR_COMPOSE=YES to webtogo.ora, but this does not seem to have cured the problem.
    From tracing, it seems that the problem is an inactive apply session that resulted in an error, being there for the user it is trying to compose. The actual block is on the table MOBILEADMIN.C$ALL_CLIENT_ITEMS.
    If an apply fails due to an error (eg: constraint violarion, trigger failure etc), it executes the statement
    UPDATE MOBILEADMIN.C$ALL_CLIENT_ITEMS SET CRR='Y' WHERE CLIENTID=? AND PUBLICATION_ITEM IN ( SELECT PUBLICATION FROM MOBILEADMIN.C$ALL_TEMPLATE_ITEMS ati WHERE ati.TEMPLATE=?):
    as part of the copy to the error queue. It also looks to execute the same statement at the beginning of the compose for the user, hence the block.
    The other odd thing is that looking at the blocks this morning, the MGP apply/compose kicked off at 7.09 am. The user synchronised at just after 8 am, by which time the MGP cycle was well into the compose phase, and there is no record of apply activity for the user within the cycle (the actual apply is in the following cycle), the the content of the blocking session was definitely apply code.
    MGP used to do all of the applys first, and then all of the composes, with a test to skip the compose if there was data in the user in queue. The upgrade to 10.2 (or one of the many patches since) looks to have changed the default behaviour to attempt an apply before each user compose, but the parameter above was supposed to set the server back to its old behaviour (ie: keep apply and compose seperate). NOTE i have not seen any of the old 'compose deferred because of unprocessed data in the in queue' messages in the compose recently either.
    Upshot is that it looks like it is still mixing apply and compose together, and where the apply hits an error, the apply thread is not closing correctly, or releasing its locks.
    Does anyone have any information about the parameters
    DO_APPLY_BFR_COMPOSE or
    SKIP_INQ_CHK_BFR_COMPOSE (this appeared with a value of NO when we added the other parameter.
    Information from oracle is that the two are mutualy exclusive (?) but they are not documented anywhere that i can find (the one reference on metalink leads to a non existant note), and oracle seem reluctant to supply any
    so PLEASE
    a) any information about the parameters
    b) any dependancies (ie: parameters not working because we are missing a patch)
    c) location of documentation
    d) any other ideas

    which version are you on?
    we are on 10.2.0.2, so unsure if this works in other versions
    The standard mobile manager parameters screen does not by default show these settings, but we were asked to add them into the webtogo.ora file in the [CONSOLIDATOR] section eg:
    [CONSOLIDATOR]
    # Installer will change these values
    SERVER_VERSION=8.1.7
    SKIP_INQ_CHK_BFR_COMPOSE=YES
    DO_APPLY_BFR_COMPOSE=NO
    RESUME_FILE_SIZE=512
    # 8.1.7
    # Installer won't change these values
    MAX_THREADS=3
    JDBC_DRIVER=oracle.jdbc.driver.OracleDriver
    once this was done we stopped and restarted the mobile server and then the new parameters will appear in the normal data synchronisation>administration>instance parameters screen
    our current setting on the live system are
    SKIP_INQ_CHK_BFR_COMPOSE YES
    DO_APPLY_BFR_COMPOSE NO
    and this does the compose whether or not there is pending data in the in queues for the client. Just my opinion, but there seems little point in doing the check as even if you force two tries of the apply process (one in the main apply phhase before the compose phase, and one just before composing for a particular user), the data in the second apply will not be picked up on fast refresh publication items as the 'snapshot' of the changes has already been done in the process logs phase

  • Blocking session query

    What's the query to find this kind of info, blocking session? eg
    535 session blocking one other session 1962, they are both coming from SP:

    This query will tell you who's blocking who...
    select (select username
              from v$session
             where sid = a.sid) blocker
         , a.sid
         , ' is blocking '
         , (select username
              from v$session
             where sid = b.sid) blockee
         , b.sid
      from v$lock a
         , v$lock b
    where a.block = 1
       and b.request 0
       and a.id1 = b.id1
       and a.id2 = b.id2query by Tom Kyte

  • How to kill the blocking session

    hi expert,
    when i m going to run the below query
    Update rcv_transactions_interface rti set rti.processing_mode_code ='BATCH'  where rti.interface_transaction_id = 3671265
    it gives the error:
    ORA-00054 resource busy and acquire with NOWAIT specified.
    i find out the blocking session by using the blow query;
    SELECT  a.SESSION_ID, a.SESSION_SERIAL#, min(A.SAMPLE_TIME) start_time,max(A.SAMPLE_TIME) end_time,a.inst_id, a.blocking_session,a.user_id,s.sql_text,A.EVENT,O.OBJECT_NAME,max(A.SAMPLE_TIME) - min(A.SAMPLE_TIME) 
    FROM GV$ACTIVE_SESSION_HISTORY a  ,gv$sql s, dba_objects o
    where a.sql_id=s.sql_id
    and A.CURRENT_OBJ# = O.OBJECT_ID
    and blocking_session is not null
    and a.user_id  != 0 -- exclude SYS user
    and a.sample_time > sysdate - 7
    and a.event = 'enq: TX - row lock contention'
    group by a.SESSION_ID, a.SESSION_SERIAL#, a.inst_id,a.blocking_session,a.user_id,s.sql_text,A.EVENT,O.OBJECT_NAME
    it gives the output
    SESSION_ID
    SESSION_SERIAL#
    START_TIME
    END_TIME
    INST_ID
    BLOCKING_SESSION
    USER_ID
    SQL_TEXT
    EVENT
    OBJECT_NAME
    MAX(A.SAMPLE_TIME)-MIN(A.SAMPLE_TIME)
    369
    45,849
    9/4/2013 8:29:33.119 AM
    9/4/2013 11:40:27.508 AM
    1
    554
    173
    SELECT POL.UNIT_PRICE   FROM PO_LINES POL  WHERE POL.PO_LINE_ID = :b1
    enq: TX - row lock contention
    PO_LINES_ALL
    +00 03:10:54.389000
    554
    18,872
    9/4/2013 8:29:33.119 AM
    9/4/2013 11:40:27.508 AM
    1
    365
    173
    SELECT POL.UNIT_PRICE,POL.QUANTITY,POL.UNIT_MEAS_LOOKUP_CODE,POL.AMOUNT   FROM PO_LINES POL  WHERE POL.PO_LINE_ID = :b1
    enq: TX - row lock contention
    JA_IN_PO_LINE_LOCATION_TAXES
    +00 03:10:54.389000
    572
    168
    9/4/2013 8:29:33.119 AM
    9/4/2013 11:40:27.508 AM
    1
    554
    173
    select line_location_id into :b0 from po_line_locations_all where line_location_id=:b1 for update of line_location_id
    enq: TX - row lock contention
    PO_LINE_LOCATIONS_ALL
    +00 03:10:54.389000
    581
    4,973
    9/4/2013 10:49:38.157 AM
    9/4/2013 10:50:39.259 AM
    1
    572
    173
    Update rcv_transactions_interface rti set rti.processing_mode_code ='BATCH'  where rti.interface_transaction_id = 3671265
    enq: TX - row lock contention
    RCV_TRANSACTIONS_INTERFACE
    +00 00:01:01.102000
    my problem is in the above  output among 4 which i have to delete so sove my issue.
    its very urgent for me.
    plz plz suggest me and how can i kill the session.
    thanks & regards
    pritesh ranjan

    priteshranjan wrote:
    hi expert,
    when i m going to run the below query
    Update rcv_transactions_interface rti set rti.processing_mode_code ='BATCH'  where rti.interface_transaction_id = 3671265
    it gives the error:
    ORA-00054 resource busy and acquire with NOWAIT specified.
    i find out the blocking session by using the blow query;
    SELECT  a.SESSION_ID, a.SESSION_SERIAL#, min(A.SAMPLE_TIME) start_time,max(A.SAMPLE_TIME) end_time,a.inst_id, a.blocking_session,a.user_id,s.sql_text,A.EVENT,O.OBJECT_NAME,max(A.SAMPLE_TIME) - min(A.SAMPLE_TIME)
    FROM GV$ACTIVE_SESSION_HISTORY a  ,gv$sql s, dba_objects o
    where a.sql_id=s.sql_id
    and A.CURRENT_OBJ# = O.OBJECT_ID
    and blocking_session is not null
    and a.user_id  != 0 -- exclude SYS user
    and a.sample_time > sysdate - 7
    and a.event = 'enq: TX - row lock contention'
    group by a.SESSION_ID, a.SESSION_SERIAL#, a.inst_id,a.blocking_session,a.user_id,s.sql_text,A.EVENT,O.OBJECT_NAME
    it gives the output
    SESSION_ID
    SESSION_SERIAL#
    START_TIME
    END_TIME
    INST_ID
    BLOCKING_SESSION
    USER_ID
    SQL_TEXT
    EVENT
    OBJECT_NAME
    MAX(A.SAMPLE_TIME)-MIN(A.SAMPLE_TIME)
    369
    45,849
    9/4/2013 8:29:33.119 AM
    9/4/2013 11:40:27.508 AM
    1
    554
    173
    SELECT POL.UNIT_PRICE   FROM PO_LINES POL  WHERE POL.PO_LINE_ID = :b1
    enq: TX - row lock contention
    PO_LINES_ALL
    +00 03:10:54.389000
    554
    18,872
    9/4/2013 8:29:33.119 AM
    9/4/2013 11:40:27.508 AM
    1
    365
    173
    SELECT POL.UNIT_PRICE,POL.QUANTITY,POL.UNIT_MEAS_LOOKUP_CODE,POL.AMOUNT   FROM PO_LINES POL  WHERE POL.PO_LINE_ID = :b1
    enq: TX - row lock contention
    JA_IN_PO_LINE_LOCATION_TAXES
    +00 03:10:54.389000
    572
    168
    9/4/2013 8:29:33.119 AM
    9/4/2013 11:40:27.508 AM
    1
    554
    173
    select line_location_id into :b0 from po_line_locations_all where line_location_id=:b1 for update of line_location_id
    enq: TX - row lock contention
    PO_LINE_LOCATIONS_ALL
    +00 03:10:54.389000
    581
    4,973
    9/4/2013 10:49:38.157 AM
    9/4/2013 10:50:39.259 AM
    1
    572
    173
    Update rcv_transactions_interface rti set rti.processing_mode_code ='BATCH'  where rti.interface_transaction_id = 3671265
    enq: TX - row lock contention
    RCV_TRANSACTIONS_INTERFACE
    +00 00:01:01.102000
    my problem is in the above  output among 4 which i have to delete so sove my issue.
    its very urgent for me.
    plz plz suggest me and how can i kill the session.
    thanks & regards
    pritesh ranjan
    According to the above, your session_id is 581 which is blocked by session_id 572 so you need to kill the 3rd session in the list.
    Thanks,
    Hussein

  • Metric threshold Blocking session count

    Hi,
    I am trying to modify the blocking session count threshould and making warning threshold as null and critical threshold > 0. When i create a blocking session in the database i get the warning for application wait class but i don't get a critical alert generated even waiting for more than an hour. Here is what i have done so far
    1. changed the warning threshold to null, critical threshold to > 0 and changed the time of collection to each 5 minutes.
    2. Creating a blocking lock in the database, when i go on the performance page of db and look at the instance locks i can see the lock being held for more than 30 minutes
    Any ideas how can i get this going will be much appreciated.

    In order to trigger the metric "blocking session count", you have to
    a. have one session which is holding the lock (not comitting)
    b. at least one session which is waiting for exactly that lock. in that case, the metric will report sid of blocking session with a value of > 0.
    Regards,
    Martin Decker
    www.ora-solutions.net

  • Oracle Blocking Session History

    Hi Folks,
    This morning the database server machine CPU hits 100% - i found a blocking session but didnt killed it as it was of the flashback session.
    The only option i thought was to restart the database.
    Now, i want to investigate the problem - any idea, how to find the cause of tht problem???
    regards,
    OraGuy

    1) Session A holding a lock that Session B is waiting on, causing session B to be temporarily blocked, assuming that's what you saw when you're talking about a "blocking session", is not particularly unusual in Oracle (or any relational database for that matter). That shouldn't cause a spike in CPU and it shouldn't require a database restart to clear the problem (at worst, you might kill the session that holds the lock, but it would normally resolve itself automatically), though. And that definitely doesn't explain a hung database if that's truly what you had.
    2) Since you mentioned AWR, can we assume that you are using the enterprise edition with the performance & tuning packs? If so, assuming you rebooted before the AWR snapshot captured information about the state of the system, you could potentially go through the ASH data (active session history) for the various sessions that were blocking and waiting to see what they were waiting on.
    Justin

  • Blocking session

    Hi all friends,
    I want to find out blocking sessions between 3.00 am to 7.00 am on dec 18,2013. Could some one help me on this please. I have a script and i would appreciate if someone can help me out to modify it.
    SELECT s1.username || '@' || s1.machine
        || ' ( SID=' || s1.sid || ' )  is blocking '
        || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
        FROM v$lock l1, v$session s1, v$lock l2, v$session s2
        WHERE s1.sid=l1.sid AND s2.sid=l2.sid
        AND l1.BLOCK=1 AND l2.request > 0
        AND l1.id1 = l2.id1
        AND l2.id2 = l2.id2

    I want to find only TX row lock

  • Blocking session  in RAC

    hi,
    How to find out the blocking sessions in RAC

    Use Google .
    Some Links :
    http://erikwramner.wordpress.com/2010/05/28/find-blocking-and-blocked-sessions/
    http://oraclespin.wordpress.com/2009/05/18/how-to-find-blocking-session/
    also mention in this thread before
    Re: Finding Locking SID in RAC environments

  • Forms related blocking sessions

    Hi,
    We use R12 applications and database 10g and wanted to kill blocking sessions that were created from forms in oracle applications.
    How to find out them?
    Regards

    query v$lock to find blocking sessions
    check v$session action field (for 'FRM:%') to see if they're forms
    the later releases of 11.5 set the v$session action field, so I assume R12 still does that - but don't have access to check.

  • Blocking sessions

    Hi ,
    I am having 9i database (9.2.0.6.0)
    I want to know ..how we can find out blocking and waiting sessions in the database whcih are holding locks on the object because of which other sessions are waiting .
    Through OEM console we can easily find out in Instance -->locks -->blocking/waiting locks
    but which view is having this informatin...?
    and how long it is locking that object in row exclusive and exclusive mode.
    i think for time we have one column ctime in the V$lock view?

    Hi,
    if you are using 9.2.0.6
    v$lock has this info
    SQL> desc v$lock;
    Name          Null?          Type
    ADDR                     RAW(8)
    KADDR                     RAW(8)
    SID                     NUMBER
    TYPE                     VARCHAR2(2)
    ID1                     NUMBER
    ID2                     NUMBER
    LMODE                     NUMBER
    REQUEST                    NUMBER
    CTIME                     NUMBER
    BLOCK                     NUMBER
    just create a query on this view v$lock and v$session.
    you can try this one.
    select s1.username || '@' || s1.machine || ' ( SID=' || s1.sid || ' ) is blocking ' || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
    from v$lock l1, v$session s1, v$lock l2, v$session s2
    where s1.sid=l1.sid and s2.sid=l2.sid
    and l1.BLOCK=1 and l2.request > 0
    and l1.id1 = l2.id1
    and l2.id2 = l2.id2 ;
    i hope it can help you.
    baidba

  • Mobile Server Session lock

    Hello Guru's,
    Since last few days our MGP cycle is not finishing and everytime there is a transaction level session lock held by 2 different Mobileadmin user in our mobile server.
    After few hours we have to forcefully killed blocking SID and then only MGP cycle finishes on Mobile server.
    Does anybody had face the same problem on their if yes kindly can you please share your experience and how to resolve this issues.
    Few thechincal details:
    1. We are running windows server 2003 with Olite database 10.2.0.2
    Thanks,
    Nirms
    Message was edited by:
    rapchik301

    We are having probably the same problem (we run on linux).
    tends to be one of two issues
    1) table C$ALL_SID_LOGGED_TABLES has a level 6 lock by an INACTIVE mobile session. killing the inactive session allows processing to continue - SR raised with Oracle
    2) contention for C$ALL_CLIENT_ITEMS in setting the dirty flag for objects that need to be processed MAY result from multiple MGP threads attampting to process the same transaction, two different transactions in the in queue for the same user or user sync around the MGP processing, but reason not yet tracked down. We have switched to a single thread until we can identify the problem

  • Find and kill "long time" blocking sessions

    Dear Experts,
    I'm looking for a way to kill sessions that are blocking for more than 5 minutes.
    I can find the blocking sessions thanks to v$lock and its block field. But how can I know when this blocking session started ?
    Best Regards,
    Guillaume

    Dear Experts,
    I'm looking for a way to kill sessions that are
    blocking for more than 5 minutes.
    I can find the blocking sessions thanks to v$lock and
    its block field. But how can I know when this
    blocking session started ?I am not sure that you are right consistent in your question
    You should not search when the blocking session started but when the blocking transaction started.
    Column logon_time in v$session gives the start time of the session.
    However what you are searching should be column start_time in v$transaction.
    SELECT t.start_time
    FROM v$transaction t, v$session s
    WHERE t.addr = s.taddr
          AND other conditions here

  • Determine blocking sessions and blocked sessions in 9iR2

    Hi,
    Running 9.2.0.7 on Solaris 2.
    We are trying to develop a query that can show us the blocked sessions and the session causing it. I have one working for 11 but for 9i, its a little more trickier. I am running these two so far:
    select s1.username || '@' || s1.machine || ' ( SID=' || s1.sid ||
           ' )  is blocking ' || s2.username || '@' || s2.machine || ' ( SID=' ||
           s2.sid || ' ) ' AS blocking_status
      from gv$lock l1, gv$session s1, gv$lock l2, gv$session s2
    where s1.sid = l1.sid
       and s2.sid = l2.sid
       and l1.BLOCK = 1
       and l2.request > 0
       and l1.id1 = l2.id1
       and l2.id2 = l2.id2;
    select do.object_name,
           row_wait_obj#,
           row_wait_file#,
           row_wait_block#,
           row_wait_row#,
           dbms_rowid.rowid_create(1,
                                   ROW_WAIT_OBJ#,
                                   ROW_WAIT_FILE#,
                                   ROW_WAIT_BLOCK#,
                                   ROW_WAIT_ROW#)
      from gv$session s, dba_objects do
    where sid = 543
       and s.ROW_WAIT_OBJ# = do.OBJECT_ID;Reason I need this is that lately we have been getting a lot of DEADLOCKS and we want to determine why this is happening a lot now and we want to start with who it is and what objects are causing it....any suggestions?

    mbobak wrote:
    There are a few critical pieces to interpreting a deadlock trace file. First, to be clear, you're getting ORA-00060, not ORA-04020 (which is a library cache deadlock), correct?
    If so, the tracefile will contain a deadlock graph. This will show the type of enqueue involved (TM or TX are the likely candidates), and the modes that locks and requests are being made.
    Then, there's the SQL which encountered the deadlock, and finally, the other SQL involved in the deadlock.
    All the above information is in the deadlock trace file.
    Using it, you ought to be able to determine root cause of the deadlock.
    If you need help understanding it, post here. If you post the deadlock graph, make sure you use code tags, or it will be unreadable.Yes we are getting the ORA-00060. This is what we get exactly from the AppTeam from the App:
    Available exception message: iims.ge.common.exception.IIMSTechnicalException : ORA-00060: deadlock detected while waiting for resourceFrom our latest Deadlock occurence we got a LMD Trace file generated. We can see the DeadLock graph and its SQL. We the enqueue of TX and it's modes. Basically everything you asked for we see it in the trace file. What we want to see is what is causing it or who is so we can fix it. Maybe I am not reading the trace file correctly. I appreciate your assistance in helping me interpret the trace file. As requested, here is the trace file.
    Dump file /var/local/oracle/logs/ora_prod_can1_lmd0_4432.trc
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning and Real Application Clusters options
    JServer Release 9.2.0.8.0 - Production
    ORACLE_HOME = /opt/oracle/9.2.0
    System name:    SunOS
    Node name:      can-clust01
    Release:        5.9
    Version:        Generic_118558-36
    Machine:        sun4u
    Instance name: ORA_PROD_CAN1
    Redo thread mounted by this instance: 0 <none>
    Oracle process number: 5
    Unix process pid: 4432, image: oracle@can-clust01 (LMD0)
    *** SESSION ID:(4.1) 2010-08-15 08:07:02.736
    open lock on RM 0 0
    *** 2010-08-15 08:07:31.353
    open lock on RM 0 0
    *** 2010-08-16 11:17:21.469
    user session for deadlock lock 40972c9c0
      pid=50 serial=6956 audsid=189500961 user: 61/IIMS_UWR
      O/S info: user: weblogic, term: unknown, ospid: , machine: can-prod03
                program: JDBC Thin Client
      application name: JDBC Thin Client, hash value=0
      Current SQL Statement:
      UPDATE T_POLICY_PROPERTY POP SET POP.PRP_EFFECTIVE_END_DATE = :B3 , POP.PRP_LAST_UPDATED_DATE = SYSDATE WHERE POP.PRP_POL_POLICY_ID = :B2 AND POP.PRP_
    PROPERTY_SEQ_NUM = 1 AND POP.PRP_EFFECTIVE_END_DATE = TO_DATE(:B1 , DATE_FORMAT)
    Global Wait-For-Graph(WFG) at ddTS[0.1] :
    BLOCKED 40972c570 5 [0x90014][0x19bb82],[TX] [131094,2] 1
    BLOCKER 40972bb98 5 [0x90014][0x19bb82],[TX] [65586,6177] 0
    BLOCKED 40972c9c0 5 [0x110014][0x12ec40],[TX] [65586,6177] 0
    BLOCKER 40972ba18 5 [0x110014][0x12ec40],[TX] [131094,2] 1
    user session for deadlock lock 40972c9c0
      pid=50 serial=6956 audsid=189500961 user: 61/IIMS_UWR
      O/S info: user: weblogic, term: unknown, ospid: , machine: can-prod03
                program: JDBC Thin Client
      application name: JDBC Thin Client, hash value=0
      Current SQL Statement:
      UPDATE T_POLICY_PROPERTY POP SET POP.PRP_EFFECTIVE_END_DATE = :B3 , POP.PRP_LAST_UPDATED_DATE = SYSDATE WHERE POP.PRP_POL_POLICY_ID = :B2 AND POP.PRP_
    PROPERTY_SEQ_NUM = 1 AND POP.PRP_EFFECTIVE_END_DATE = TO_DATE(:B1 , DATE_FORMAT)
    Global Wait-For-Graph(WFG) at ddTS[0.2] :
    BLOCKED 40972c9c0 5 [0x110014][0x12ec40],[TX] [65586,6177] 0
    BLOCKER 40972ba18 5 [0x110014][0x12ec40],[TX] [131094,2] 1
    BLOCKED 40972c570 5 [0x90014][0x19bb82],[TX] [131094,2] 1
    BLOCKER 40972bb98 5 [0x90014][0x19bb82],[TX] [65586,6177] 0
    *** 2010-08-16 11:17:42.495
    user session for deadlock lock 4098bcd08
      pid=59 serial=981 audsid=189501588 user: 61/IIMS_UWR
    O/S info: user: weblogic, term: unknown, ospid: , machine: can-prod03
                program: JDBC Thin Client
      application name: JDBC Thin Client, hash value=0
      Current SQL Statement:
      UPDATE T_POLICY_PROPERTY POP SET POP.PRP_EFFECTIVE_END_DATE = :B3 , POP.PRP_LAST_UPDATED_DATE = SYSDATE WHERE POP.PRP_POL_POLICY_ID = :B2 AND POP.PRP_
    PROPERTY_SEQ_NUM = 1 AND POP.PRP_EFFECTIVE_END_DATE = TO_DATE(:B1 , DATE_FORMAT)
    Global Wait-For-Graph(WFG) at ddTS[0.3] :
    BLOCKED 41228b128 5 [0x70001][0x178a52],[TX] [131100,2] 1
    BLOCKER 4098bade8 5 [0x70001][0x178a52],[TX] [65595,583] 0
    BLOCKED 4098bcd08 5 [0x130025][0x1475c9],[TX] [65595,583] 0
    BLOCKER 412275b78 5 [0x130025][0x1475c9],[TX] [131100,2] 1
    user session for deadlock lock 4098bcd08
      pid=59 serial=981 audsid=189501588 user: 61/IIMS_UWR
      O/S info: user: weblogic, term: unknown, ospid: , machine: can-prod03
                program: JDBC Thin Client
      application name: JDBC Thin Client, hash value=0
      Current SQL Statement:
      UPDATE T_POLICY_PROPERTY POP SET POP.PRP_EFFECTIVE_END_DATE = :B3 , POP.PRP_LAST_UPDATED_DATE = SYSDATE WHERE POP.PRP_POL_POLICY_ID = :B2 AND POP.PRP_
    PROPERTY_SEQ_NUM = 1 AND POP.PRP_EFFECTIVE_END_DATE = TO_DATE(:B1 , DATE_FORMAT)
    Global Wait-For-Graph(WFG) at ddTS[0.4] :
    BLOCKED 4098bcd08 5 [0x130025][0x1475c9],[TX] [65595,583] 0
    BLOCKER 412275b78 5 [0x130025][0x1475c9],[TX] [131100,2] 1
    BLOCKED 41228b128 5 [0x70001][0x178a52],[TX] [131100,2] 1
    BLOCKER 4098bade8 5 [0x70001][0x178a52],[TX] [65595,583] 0Let's see what we can get out of this now :)

  • Determinig the user of the blocking session.

    I have an EBS system where users are creating locks that block others . I know that this is a user issue and they should use the system properly and not make changes and not save or rollback.
    However , Every once in a while I get the same issue , A session is making a lock which is holding all the requests . All works fine after I kill the session but I need to identify the user who is doing this so I can talk to him and educate him on how to use the system properly .
    The issue is the session “ as expected “ logs into the database using the apps user . How can I identify the user creating this issue ??? .
    I am looking for apps username like sysadmin, tareq, mike,...
    Thanks,
    Tareq

    Hi Tareq;
    Please try below query which show who makes block
    select 'alter system kill session ' || chr(39) || s.sid || ', ' || s.serial# || chr(39) || ';', s.inst_id,
    'kill -9 ' || p.spid, s.username, s.module
    from gv$session s, gv$process p
    where p.inst_id = s.inst_id
    and p.addr = s.paddr
    and s.type <> 'BACKGROUND'
    and s.sid in (
    SELECT DECODE(request, 0, sid, -1) sid
    FROM gV$LOCK
    WHERE (id1, id2, TYPE) IN (SELECT id1, id2, TYPE FROM GV$LOCK WHERE lmode = 0)
    Also check this:
    select a.SID "Blocking Session", b.SID "Blocked Session"
    from v$lock a, v$lock b
    where a.SID != b.SID
    and a.ID1 = b.ID1
    and a.ID2 = b.ID2
    and b.request > 0
    and a.block = 1;
    Regard
    Helios

Maybe you are looking for