Script to kill blocking sessions

We use Oracle 10. We have a test database used solely for training and I need the give the trainer the ability to kill all the blocking sessions when a block(s) is holding up
the entire class.
My idea was to create a simple form on our Oracle menu- containing just a single button that when pressed would trigger the script. One press of the button
to kill each and every blocking session. I have no clue as to how to write a script of this nature. Would appreciate any advice.
Regards,
Sandy

This is easier said than done. Numerous reasons. Here's a couple:
You cannot rely on using v$session to identifying blocked sessions.
Some user sessions may be blocked by a system process (e.g. log writer), which means you cannot unblock the user sessions by killing the blocking session. (especially when running into an Oracle bug where a user session will spin on "+enq: RO - fast object reuse+" when dropping an object and then being shown as blocked by a system session/process).
Killing a session in Oracle is a misnomer as the "+alter system kill session+" is a request and not a command. The relevant user session needs to terminate itself (kind of like assisted suicide). No other process actually kills the physical process (or thread) executing that user session. Thus if that user session is waiting on some external response or event, it will be unable (now and forever) to respond to that kill request. In such a case, the only alternative is killing the physical process instead. (or shutting down the database)
A blocking session could be a job process that contains problematic code that leads to the blocking/serialisation. Killing that session will simply fail the job after which the job queue manager will restart the session again.. 16 times in succession. Only then will it mark that job entry as broken and cease trying to restart it.
So killing blocking sessions? It is not easy to identify blocking processes, they cannot always be killed, and even when you do kill them, they may simply reincarnate as a new session.
So what is the solution then?
Blocking sessions are not "+A Bad Thing+". There are very good and technically sound reasons for serialisation. When it does become a problem, there's something more to it. And blindly killing blocking sessions in such a case is treating the symptom of a problem and ignoring the problem all together. Find the reason for this serialisation and address that.

Similar Messages

  • Scripts for killing blocking oracle processes?

    We are having a problem in that when a user disconnects improperly, the oracle processes on our Oracle Apps box don't die properly and rows remain locked. For other terminal based versions, the script to kill the process is pretty simple, but for the web-based, java interface, it's unclear how I would go about doing this. Does anyone have scripts for doing this that could run via cron? The applications are running on solaris 2.6.
    Thanks,
    Nathan Olla
    Unix Sys Admin

    Take a look at note 130709.1 on Metalink. It contains configuration info for httpds.conf - your Apache configuration file. You can use this to time-out sessions properly. Hope this helps.

  • Killing all sessions at once who are locking the objects

    Hello all,
    i am working in 9i Oracle RDBMS on AIX IBM OS
    most of the time we face locking issue and there comes more then different 50 sessions which locking different tables.
    here is my script to find out what sessions are locking what tables.
    set lines 200
    set pages 50000
    col SID for 99999
    col SERIAL# for 999999
    col username format a12
    col sql format a55
    col event format a50
    col program format a40
    col MINS for 9999
    col ID1 for 999999
    col object_name for a35
    col locktype for a8;
    select  /*+ ORDERED */ s.sid,s.serial#,s.status,round(s.last_call_et/60) MINS,s.program,l.ID1,d.object_name,d.object_type,l.type as locktype
    from v$lock l,v$session s, dba_objects d
    where l.sid = s.sid
    and l.ID1 = d.object_id
    and s.username = 'MULDMS'
    and last_call_et > 120 and l.type <> 'TX' order by s.status,MINS,l.ID1,l.type; and the out put it gives something like
      SID SERIAL# STATUS    MINS PROGRAM                                      ID1 OBJECT_NAME                         OBJECT_TYPE        LOCKTY
    8981    1069 ACTIVE       2 frmweb@Appsdms31 (TNS V1-V3)               30407 VH_BTN                              TABLE              TM
    1642     512 ACTIVE      15 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
      699    1787 ACTIVE      17 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                      TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    1912    1655 ACTIVE      18 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    1912    1655 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    1754    1582 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     30643 VT_CHECK_INOUT                      TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                      TABLE              TM
    10708     982 ACTIVE      19 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    5428     855 ACTIVE      19 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10708     982 ACTIVE      19 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    5428     855 ACTIVE      19 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    10278     897 ACTIVE      20 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    6261    1056 ACTIVE      20 frmweb@appsdms12 (TNS V1-V3)               28846 AM_DOCS                             TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10278     897 ACTIVE      20 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6261    1056 ACTIVE      20 frmweb@appsdms12 (TNS V1-V3)               30407 VH_BTN                              TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    3521     717 ACTIVE      20 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     30643 VT_CHECK_INOUT                     TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                   TABLE              TM
    9131    1002 INACTIVE     2 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
    4887    1040 INACTIVE     2 [email protected] (TNS V1-V3)     30455 VH_PSF                              TABLE              TM
      151    1982 INACTIVE     2 [email protected] (TNS V1-V3)     80224 RD_ENQEXD                           TABLE              TM
      846     988 INACTIVE     3 [email protected] (TNS V1-V3)    29228 GM_VIN                              TABLE              TM
    5364    1149 INACTIVE     3 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    9934     789 INACTIVE     3 [email protected] (TNS V1-V3)     30455 VH_PSF                              TABLE              TM
    7511    1092 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
    3595    1104 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
      846     988 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
      945     670 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TMand then i have to kill the session one by one . thaat is a tedious task to do.
    i want to modify this script which will give me all the kill statement and i just have to run it
    can someone help me in this regard as i am weak in sql/plsql
    thanks and many thanks

    >
    i want to modify this script which will give me all the kill statement and i just have to run it
    >
    Karthick's script will 'kill' the sessions but before you use that script you may want to read the docs about the KILL and DISCONNECT clauses.
    See the DISCONNECT SESSION and KILL SESSION clauses in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm#sthref4724
    >
    DISCONNECT SESSION Clause
    Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever).
    The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.
    KILL SESSION Clause
    The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources.
    IMMEDIATE Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.
    >
    For DISCONNECT the IMMEDIATE clause will recover the session state 'immediately'.
    Using KILL, even with the IMMEDIATE clause, you are telliing Oracle to roll back any ongoing transactions and that can take a lot of time.
    Make sure you are really doing the operation you want to do. If you want to get the locks released immediately you need to use 'DISCONNECT IMMEDIATE'.

  • Find blocking sessions based on forms

    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?

    You can use the resource manager to kill the blocking sessions.
    Also you can query to find the blocking sessions:
    select SID, SERIAL#, machine, USERNAME, status, BLOCKING_SESSION
    from v$session where BLOCKING_SESSION IS NOT NULL
    UNION ALL
    select A.SID, A.SERIAL#, A.machine, A.USERNAME, A.status, A.BLOCKING_SESSION
    from v$session A, V$SESSION b WHERE A.SID=B.BLOCKING_SESSION
    order by machine, status;

  • 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.

  • Kill blocker automatically

    Hi
    Is there a way to automate killing blocking session in oracle ?
    i.e if a session is blocking more than 5 minutes, it should be killed automatically.
    Do we need a trigger to achieve this ?

    See MAX_IDLE_BLOCKER_TIME (dbms_resource_manager.create_plan_directive) - the maximum amount of time in seconds that a session can be idle while blocking another session's acquisition of a resource. Default is NULL, which implies unlimited.
    http://docs.oracle.com/cd/E14072_01/server.112/e10595/dbrm003.htm
    --Creating plan directive
    exec dbms_resource_manager.create_plan_directive (
      plan=>'prod_plan',
      group_or_subgroup=>'dss_group',
      comment=>'Limit idle time',
      max_idle_time=>900,
    max_idle_blocker_time=>300);
    --http://www.datadisk.co.uk/html_docs/oracle/resource_manager.htmEdited by: stefan nebesnak on Feb 4, 2013 11:49 AM

  • Kill the session Using Pl/sql Script

    Hi,
    I wrote a PL/SQL Script which kills the Specified Schema name..... the Script Run Successfully i got this output message "PL/SQL procedure successfully completed." But the Problem is in session status the status is in KILLED" state for more than 30 minutes.
    Please Advice Why the Session in Killed State for more than 30 minutes and please tell me how to kill the session immediate;
    I am Using Oracle DB 11g R1 and OS is Windows 2003 Server R2
    My Pl/sql Script
    SET SERVEROUTPUT ON;
    DECLARE
    KILLER1 V$SESSION.SID%TYPE;
    KILLER2 V$SESSION.SERIAL#%TYPE;
    CURSOR KILL_SESSION IS SELECT SID,SERIAL# FROM V$SESSION WHERE SCHEMANAME='NAME';
    BEGIN
    OPEN KILL_SESSION;
    LOOP
    FETCH KILL_SESSION INTO KILLER1,KILLER2;
    EXIT WHEN KILL_SESSION%NOTFOUND;
    DBMS_OUTPUT.put_line ('ALTER SYSTEM KILL SESSION '''||KILLER1||','||KILLER2||''' IMMEDAITE');
    EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
    END LOOP;
    IF (KILLER1 > 0)
    THEN
    EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
    END IF;
    CLOSE KILL_SESSION;
    END;
    Thank You
    Shan

    Hello,
    In fact you may use orakill it's an Oracle utility for Windows so as to Kill the thread corresponding
    to the session.
    It's equivalent to a kill -9 on Unix.
    Please find here a link about the use of orakill:
    http://articles.techrepublic.com.com/5100-10878_11-5224960.html
    Hope this help.
    Best regards,
    Jean-Valentin
    Edited by: Lubiez Jean-Valentin on Mar 27, 2010 5:17 PM

  • 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

  • Looking for a script to kill all inactive sessions

    Does anyone have a script to kill all INACTIVE sessions (with EXECUTE IMMEDIATE)?

    I suggest you to specify which OS you are talking about.
    The inactive status on the V$SESSION doesn't mean the user is not doing any thing, it only means the oracle server process is not processing any thing by the time it was queried. On OLTP systems Oracle Server Processes remain INACTIVE for more than 95% of the time, so it is advisable to configure shared servers.
    If you are really concerned about idle time, then I suggest you to configure profiles.
    On the pool mechanism you should address the microsoft side, if this, as far as I understood and guessed, application server is IIS.
    I suggest you further reading on the Killing sessions script and different session status (check the sniped status) here:
    Re: session inactive ??
    Re: make a job to delete the sniped sessions
    Re: How do I put a timeout in my DataBase?
    Re: Killing Session with Locks in Linux
    ~ Madrid

  • 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

  • How to use a script to kill only forms sessions idle for over 30 minutes?

    We want to use a script to kill forms users idle for over 30 minutes, but we don't want to kill background concurrent processes waiting for resources. even though we set up the timeout but it won't work for users who exit forms ungracefully.
    thanks!

    Java runs at the serverside, while you need a clientside solution. Javascript is perfectly suitable. Pass the current maxInactiveInterval() value to a Javascript variable and write a function around it. You can use for example the onkeypress attribute of the body to clear the timeout counter.

  • Kill a session that is holding library cache lock!!

    Hi, all.
    What will happen if I kill a session that is holding library cache lock??
    Currently, the session is pending with library cache lock.
    I cannot see any locks in v$lock.
    If I kill the session, will oracle release the library cache lock??
    Thanks and Regards.

    What output do you get from the following script?
    liblock.sql:
    select decode(lob.kglobtyp, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
                          4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE',
                          7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
                          11, 'PACKAGE BODY', 12, 'TRIGGER',
                          13, 'TYPE', 14, 'TYPE BODY',
                          19, 'TABLE PARTITION', 20, 'INDEX PARTITION', 21, 'LOB',
                          22, 'LIBRARY', 23, 'DIRECTORY', 24, 'QUEUE',
                          28, 'JAVA SOURCE', 29, 'JAVA CLASS', 30, 'JAVA RESOURCE',
                          32, 'INDEXTYPE', 33, 'OPERATOR',
                          34, 'TABLE SUBPARTITION', 35, 'INDEX SUBPARTITION',
                          40, 'LOB PARTITION', 41, 'LOB SUBPARTITION',
                          42, 'MATERIALIZED VIEW',
                          43, 'DIMENSION',
                          44, 'CONTEXT', 46, 'RULE SET', 47, 'RESOURCE PLAN',
                          48, 'CONSUMER GROUP',
                          51, 'SUBSCRIPTION', 52, 'LOCATION',
                          55, 'XML SCHEMA', 56, 'JAVA DATA',
                          57, 'SECURITY PROFILE', 59, 'RULE',
                          62, 'EVALUATION CONTEXT',
                         'UNDEFINED') object_type,
           lob.KGLNAOBJ object_name,
           lk.KGLLKMOD lock_mode_held,
           lk.KGLLKREQ lock_mode_requested,
           ses.sid,
           ses.serial#,
           ses.username
      FROM
           x$kgllk lk,
           v$session ses,
           x$kglob lob,
           v$session_wait vsw
      WHERE
       lk.KGLLKUSE = ses.saddr and
       lk.KGLLKHDL = lob.KGLHDADR
       and lob.kglhdadr = vsw.p1raw
       and vsw.event = 'library cache lock'
    order by lock_mode_held desc
    /It should provide a locking graph of all sessions that are blocked on the 'library cache lock' event, and what sessions are the blockers.
    Hope that helps,
    -Mark
    PS It needs to run as SYSDBA, due to the X$KGLLK reference.

  • Script to kill long running reports in OBIEE

    Hi
    I have requirement to kill long running reports . I am using OBIEE version 10.1.3.4.0 which has a bug where it is not taking query limits governor and the reports are not getting killed if i am setting that parameter in RPD.
    Oracle support has advised me to upgrade to next version, but for now, i cannot upgrade.
    Can anyone suggest me script to run on obiee app server that can kill long running reports on obiee and database server.
    I have AIX server and all reports run on database with same functional ID that is being used for ETL as well to Analytics database.

    Shikhs17 wrote:
    Hi
    I have requirement to kill long running reports . I am using OBIEE version 10.1.3.4.0 which has a bug where it is not taking query limits governor and the reports are not getting killed if i am setting that parameter in RPD.
    Oracle support has advised me to upgrade to next version, but for now, i cannot upgrade.
    Can anyone suggest me script to run on obiee app server that can kill long running reports on obiee and database server.
    I have AIX server and all reports run on database with same functional ID that is being used for ETL as well to Analytics database.Do you want to enforce the limitation on the database to automatically kill running sessions that run over specific period of time?

  • PL/SQL procedure to kill inactive session

    Hi all ,
    Please i am trying to write a procedure to kill inactive sessions of the shema 'TESTSCHEMA' .This is my first procedure , am not use to pl/sql but i went through many turtorial but have some errors at compliation .when i try to compile the procedure the errors are as below :
    15:50:28 Start Find Objects [TESTSCHEMA@TESTDB_UNIX(2)] ...
    15:50:28 End Find Objects [TESTSCHEMA@ TESTDB_UNIX(2)]
    15:50:32 Start Compiling 1 object(s) ...
    15:50:32 Executing ALTER PROCEDURE fib_dead_cnx_cleanup COMPILE ...
    15:50:32 [13:2] PL/SQL: ORA-00933: SQL command not properly ended
    15:50:32 [9:3] PL/SQL: SQL Statement ignored
    15:50:32 [18:12] PLS-00103: Encountered the symbol "(" when expecting one of the following:
    15:50:32 constant exception <an identifier>
    15:50:32 <a double-quoted delimited-identifier> table LONG_ double ref
    15:50:32 char time timestamp interval date binary national character
    15:50:32 nchar
    15:50:32 The symbol "<an identifier>" was substituted for "(" to continue.
    15:50:32 [18:21] PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
    15:50:32 := ; not null default character
    15:50:32 The symbol "; was inserted before "LOOP" to continue.
    15:50:32 [27:8] PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    15:50:32 begin case declare exit for goto if loop mod null pragma
    15:50:32 raise return select update while with <an identifier>
    15:50:32 <a double-quoted delimited-identifier> <a bind variable> <<
    15:50:32 close current delete fetch lock insert open rollback
    15:50:32 savepoint set sql execute commit forall merge pipe
    15:50:32 Compilation complete - 5 error(s) found
    15:50:32 End Compiling 1 object(s)
    below is the procedure code :
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
    l_serial     CHAR(100);
    l_sid CHAR (100);
    l_sid_serial CHAR(100);
    l_count      NUMBER(10,0);
    CURSOR session_cur IS
              SELECT sid,serial#,sid||','||serial# as sid_serial
         FROM v$session
         WHERE username='EBBFCAT' and schemaname='TESTSCHEMA'
         and status='INACTIVE'
    BEGIN
         BEGIN
         l_count := 0;
                   OPEN session_cur;
                        WHILE ( 1 = 1) LOOP
                             BEGIN
                                  FETCH session_cur INTO l_sid ,l_serial,l_sid_serial ;
                                       EXIT WHEN session_cur%NOTFOUND ;
                                  BEGIN
                                       alter system kill session 'l_sid_serial' ;
                                  END;     
                             END;
                        END;
                   CLOSE session_cur;
         END;
    END FIB_DEAD_CNX_CLEANUP;
    Thanks

    Hi,
    Never write, let alone post, unformatted code.
    When posting any formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Among the benefits of formatting: you can indent to show the extent of blocks, such as BEGIN-END.
    Different types of blocks need modifiers after the end, such as "END *IF* " and " END *LOOP* ". If each opening statement (BEGIN, IF, LOOP) is directly above its corresponding END, then it's easy to check if you got the right modifier.
    Here's what you code looks like with some formatting, and a couple of corrections added. Look for -- comments.
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
         l_serial     CHAR(100);
         l_sid          CHAR (100);
         l_sid_serial     CHAR(100);
         l_count          NUMBER(10,0);
         CURSOR session_cur IS
                SELECT  sid
                ,       serial#
                ,       sid     || ','
                                      || serial#     as sid_serial
                FROM     v$session
                WHERE      username     = 'EBBFCAT'
                and     schemaname     = 'TESTSCHEMA'
                and     status          = 'INACTIVE';          -- need semicolon here
    BEGIN
         BEGIN                                   -- Why?
              l_count := 0;
              OPEN session_cur;
              WHILE ( 1 = 1)
              LOOP
                    BEGIN                         -- Why?
                         FETCH  session_cur
                         INTO   l_sid
                         ,          l_serial
                         ,          l_sid_serial ;
                               EXIT WHEN session_cur%NOTFOUND ;
                         BEGIN                    -- Why?
                             alter system kill session 'l_sid_serial' ;    -- Not a PL/SQL command
                               END;
                          END;
                END LOOP;                         -- LOOP ends with END LOOP
                CLOSE session_cur;
            END;
    END      FIB_DEAD_CNX_CLEANUP;Take baby steps.
    I've been wrtiing PL/SQL for 20 years, and I would never write that much code at once. If you're a beginner, all the more reason to start small. Write as little as possible, test, debug and test again (if necessary). When you have someting working, add 2 or 3 more lines and test again.
    It looks like you have three BEGIN statements that don't serve any purpose. You should get rid of them (and their corresponding END statements, of course).
    One error I did not fix: ALTER SYSTEM is not a PL/SQL statement. It's a SQL statement. You can run a SQL statement inside PL/SQL by using dynamic SQL, where you construct a string containing the SQL statement, and then use dbms_sql or EXECUTE IMMEDIATE to run it.
    Edited by: Frank Kulash on Aug 18, 2009 12:37 PM

  • Cannot kill a session that is running a query on a linked server in SQL Server 2008 R2

    Hi,
    Cannot kill a session that is running a query on a linked server  in SQL Server 2008 R2.
    When I try to kill, it status shown as "KILLED/ROLLBACK"
    I have facing the issue from long back. I searched many and none of them worked for me
    Any help is greatly appreciated
    Thanks
    Jaison
    Carver

    I guess its stuck, can you see some blocking or any other process blocking the rollback.
    can you check rollback status using below command. Or you can use sp_who2 and check status column
    select percent_complete,estimated_completion_time from sys.dm_exec_requests
    where spid=xxx
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

Maybe you are looking for