Script to kill the locks

Hi all,
Good day..
DB version is 10.2.0.4 I need to write a script which has to kill any table locks in the DB which is more than 10 minutes.
thanks,
baskar.l

hi thanks saad for your valuable suggestions..
i modified the script accordingly and it executed.
SQL> DECLARE
  2  CURSOR c IS
  3  SELECT c.owner,
  4        c.object_name,
  5        c.object_type,
  6        b.SID,
  7        b.serial#,
  8        b.status,
  9        b.osuser,
10        b.machine
11   FROM v$locked_object a, v$session b, dba_objects c
12   WHERE b.SID = a.session_id AND a.object_id = c.object_id
13   and c.object_name in ('JSW_CRM_C_HR_COIL_INFO','T_SPCL_BARCODE_CRS2');
14  c_row c%ROWTYPE;
15  l_sql VARCHAR2(100);
16  BEGIN
17  OPEN c;
18  LOOP
19  FETCH c INTO c_row;
20  EXIT WHEN c%NOTFOUND;
21  l_sql := 'alter system kill session '''||c_row.SID||','||c_row.serial#||'''';
22  EXECUTE IMMEDIATE l_sql;
23  END LOOP;
24  CLOSE c;
25  END;
26  /
PL/SQL procedure successfully completed.thanks,
baskar.l

Similar Messages

  • It it necessary to kill the locks

    Hello World ,
    I fired this query to get the locks
    SELECT l.inst_id,
    SUBSTR(L.ORACLE_USERNAME,1,8) ORA_USER,
    SUBSTR(L.SESSION_ID,1,3) SID,
    S.serial#,
    SUBSTR(O.OWNER||'.'||O.OBJECT_NAME,1,40) OBJECT, P.SPID OS_PID,
    DECODE(L.LOCKED_MODE, 0,'NONE',
    1,'NULL',
    2,'ROW SHARE',
    3,'ROW EXCLUSIVE',
    4,'SHARE',
    5,'SHARE ROW EXCLUSIVE',
    6,'EXCLUSIVE',
    NULL) LOCK_MODE
    FROM sys.GV_$LOCKED_OBJECT L
    , DBA_OBJECTS O
    , sys.GV_$SESSION S
    , sys.GV_$PROCESS P
    WHERE L.OBJECT_ID = O.OBJECT_ID
    and l.inst_id = s.inst_id
    AND L.SESSION_ID = S.SID
    and s.inst_id = p.inst_id
    AND S.PADDR = P.ADDR(+)
    order by l.inst_id
    There are 4 lock , all of them 'ROW EXCLUSIVE' , is it necessary to kill them? and how to find the reason?

    my database version is
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    SQL> select blocking_session_status,blocking_session, blocking_instance from v$session ;
    BLOCKING_SE BLOCKING_SESSION BLOCKING_INSTANCE
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    UNKNOWN
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    BLOCKING_SE BLOCKING_SESSION BLOCKING_INSTANCE
    NO HOLDER
    UNKNOWN
    UNKNOWN
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NOT IN WAIT
    NO HOLDER
    VALID 1023 1
    BLOCKING_SE BLOCKING_SESSION BLOCKING_INSTANCE
    NO HOLDER
    VALID 1023 1
    UNKNOWN
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    UNKNOWN
    NO HOLDER
    NO HOLDER
    BLOCKING_SE BLOCKING_SESSION BLOCKING_INSTANCE
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    NO HOLDER
    BLOCKING_SE BLOCKING_SESSION BLOCKING_INSTANCE
    NO HOLDER
    NO HOLDER
    46 rows selected.

  • 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

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

  • Kill the Blocker

    Hi all,
    11.2.0.1
    We have been long bothered by a blocking process that prevents our batch process to successfully complete during midnight.
    This script helped me to identify the blocker, but did not provide the serial#r for killing the process.
    select distinct s1.username ||'@'|| s1.machine ||'(INST=' || s1.inst_id ||' SID= '|| s1.sid ||')
    is blocking '|| s2.username || '@' || s2.machine || ' (INST=' || s1.inst_id||' SID='||s2.sid ||')'    
    AS blocking_status, s2.program,s3.sql_id, s3.sql_text from gv$lock l1, gv$session s1, gv$lock l2, gv$session s2, v$sql s3
        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
        and s2.sql_id = s3.sql_id;
    It this regard, to prove that I am not "lazy" I am revising the script and tell me if it correct by testing at your respective db.
    Here is my revised script:
    select distinct 'alter system kill session '||''''||s1.sid||','||s1.serial#||',@'||s1.inst_id||'''' from gv$lock l1, gv$session s1, gv$lock l2, gv$session s2, v$sql s3
        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
        and s2.sql_id = s3.sql_id;
    Please check it it will kill the right process?
    Thanks a lot,
    zxy

    yxes2013 wrote:
    You did not check it
    You did not even noticed the redundant conditions which Nicolas has observed.
        and l2.id2=l2.id2
    Please check if it can be removed or there has been substitute or overwritten conditions missing?
    Thanks
    Troll.

  • 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

  • Why it is taking too much time to kill the process?

    Hi All,
    Today,one of my user ran the calc script and the process is taking too much time, then i kill the process. I am wondering about one thing here even it is taking too long to kill the process, generally it will not take more than 2 sec. I did this through EAS.
    After that I ran Maxl statement
    alter system kill request 552599515;
    there is no use at all.
    Please reply if you have any solutions to kill this process.
    Thanks in advance.
    Ram.

    Hi Ram,
    1. Firstly, How much time does your calculation scripts normally run.
    2. While it was running, you can go to the logs and monitor where exactly the script is taking time .
    3. Sometimes, it does take time to cancel a transaction ( as it might be in between).
    4. Maxl is always good to kill ,as you did . It should be succesful . Check the logs what it says ,and also the "sessions" which might say "terminating" and finish it off.
    5. If nothing works ,and in the worst case scenarion , if its taking time without doing anything. Then log off all the users and stop the databas and start it .
    6. Do log off all the users, so that you dont corrupt any filter related sec file.
    Be very careful , if its production ( and I assume you have latest backups)
    Sandeep Reddy Enti
    HCC
    http://hyperionconsultancy.com/

  • Indesign server web service - where is the support to upload a file with the script and download the result?

    Hi,
    I am working on a POC that is supposed to convert indd files to pdf (i.e. using of course the indesign server). Basically I want to call the IDS Web Service (located on a different machine perhaps), pass in the input file, the conversion script and retrieve the result as part of the WebService call? 
    Browsing the documentation, examples, etc in the SDK, I couldn't see how the above can be achieved without the client handling the file transfer. Surely I must be missing something ...
    thanks
    Chris

    What do you mean with POC?
    InDesign Server is too precious (i.e. license cost) to waste its time with file transfers.
    For a smaller scale, let a separate process (some http or smb server) on the same server hardware handle the files - so that the InDesign Server can access them on the fastest local volume.
    If you plan for bigger, use a dedicated server for file sharing (your choice of SMB, NFS or whatever), where the input files are prepared by the client process, so that your load balancer can immediately point the next free instance of the InDesign server farm to the file. In that case be prepared for some try and error - high speed file sharing can be tricky with files written from one side not yet visible or incomplete to the other side, locking problems, Unicode file name trouble, unexpected time stamps and so forth.
    Btw, there is also an InDesign Server forum which would be more appropriate for such discussions.
    Dirk

  • How to kill the process running on specific port in Solaris 10

    Hi
    As I want to kill the proces running on port 8080 in my solaris 10 box. is there any command to do the same.
    Thanks
    Rajan

    A quick google, found lots of scripts... I found the script below @ Christopher Hubbell's blog - I've modified it to pump out the command name.
    ---->>>>>>BUT let's just say it would be quicker to got to sunfreeware.com and download lsof.
    the 'lsof -i " option will give you the process id, which you can use kill _pid_ to kill the id.
    Christopher's modded script (my edits in bold):
    #!/bin/sh
    if [ `/usr/xpg4/bin/id -u` -ne 0 ]; then
    echo "ERROR: This script must run as root to access pfiles command."
    exit 1
    fi
    if [ $# -eq 1 ]; then
    port=$1
    else
    printf "which port?> "
    read port
    echo "Searching for processes using port $port...";
    echo
    fi
    for pid in `ps -ef -o pid | tail +2`
    do
    foundport=`/usr/proc/bin/pfiles $pid 2>&1 | grep "sockname:" | egrep "port: $port$"`
    if [ "$foundport" != "" ];
    then
    pname=`ps -ef -o pid -o comm |grep $pid| awk '{print $2}'`
    echo "process name: $pname, $foundport"
    fi
    done
    exit 0
    Tom de

  • Unable to Kill the Consolidation task for HFM application

    User is unable to kill the Consolidation task in HFM application. Consolidation process which usually takes 2 mins has been showing status as running @79% since 4-6 hrs. User ID is has the provisioning manager, lock Data and unlock data provisions in Shared Services. The stop task button in the Running Tasks list is not enabled . Our Support team has advanced user access which is not also able to stop the task. Please note Admin access is restricted and not allowed for such tasks.

    I would check the HFM Log to see if you find anything referring to locked / blocked records.
    If your HFM app is killed in the middle of consolidating or performing other activities that requires it to 'lock' a segment of memory in the database, that 'lock' is still held on those data points when the application restarts.
    If you then try to perform another consolidation and it hits one of those locked data points, it will sit there for a very long amount of time waiting for the 'lock' to clear.
    I forget the exact error message that you will find in the log AND I forget the timeout period; however, it sucks having to wait through that.
    The other possibility that comes to mind is that the consolidation really aborted and the status didn't update. (once again check the logs)
    Charles

  • 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

  • Is there a way to keep the screen from lighting up every time an email comes in, but still be able to see the email on the lock screen when you press the home button?

    Is there a way to keep the screen from lighting up everytime an email comes in, but still be able to see the email on the lock screen when you press the home button?  This is killing my battery, but also is kinda the whole point of the notification center in my mind.

    This is something I've been wondering. I am a bit like you, I like being able to have a glance at emails or Facebook updates without having to log in, and I think it would be great to be able to turn off the notification switching the screen on, especially for emails as I do get a lot, and Facebook, but I somehow doubt it is possible.
    I am currently monitoring how much this eats up my battery charge. On a normal day, after an overnight charge, I would probably still have 30%-40% left when I leave work in the evening. Today, I was down to 48% by lunchtime, where I've usually got a good 60-70% left... Might have to turn email notifications off on lock screen until it's possible to have them appearing in the list without flashing me...

  • How to retrieve the "Lock User"?

    Hi,
    i want to change a single record, but another user locks the record.
    How could i get the User, who is locking the record?
    Thx
    Wolle

    Hi,
    May be check this out:
    http://www.jlcomp.demon.co.uk/faq/row_locker.html
    OR
    UTLLOCKT.SQL
    The UTLLOCKT.SQL script displays a simple character lock wait-for graph in tree structured fashion. Using any ad hoc SQL tool (such as SQL*Plus) to execute the script, it prints the sessions in the system that are waiting for locks and the corresponding blocking locks. The location of this script file is operating system dependent. (You must have run the CATBLOCK.SQL script before using UTLLOCKT.SQL.)

  • How is it possible that in preference the lock by Time Machine is unlocked the day after i locked it

    How is it possible that in preference the lock by Time Machine is unlocked the day after i locked it

    The crossdomain security policy stuff is annoying, but it's there to prevent this sort of scenario:
    Joe Blackhat writes a flash game about Bob the Goldfish. Joe Blackhat decides that a fun thing to do might be to write an SMTP client in ActionScript so that fans of Bob the Goldfish could unknowingly send spam while they play. Bob the Goldfish game goes viral. Everyone is playing it and spam volume bajillion-duples. Spam kills the internet. The End.
    This is facetious and contrived, but without crossdomain security policies, the internet would be a much more dangerous place. JavaScript has even more restrictive crossdomain policies. I don't think this is going away.

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

Maybe you are looking for