How to Remove a Session Lock or Kill a Blocking Session
Oracle R12: How to Remove a Session Lock or Kill a Blocking Session
When working with Oracle R12, you may encounter situations where a database session blocks other users or processes. In such cases, you can identify the blocking session and terminate it if necessary.
Step 1: Identify the Blocking Session
Run the following SQL query to find the SID and SERIAL# of the blocking session.
SELECT blocking_session,
sid,
serial#,
event
FROM v$session
WHERE blocking_session IS NOT NULL;
Sample Output
| BLOCKING_SESSION | SID | SERIAL# | EVENT |
|---|---|---|---|
| 125 | 240 | 56789 | enq: TX - row lock contention |
Note: Record the SID and SERIAL# values from the output. These values are required to terminate the session.
Step 2: Kill the Blocking Session
Replace sid and serial# with the values returned by the previous query.
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
Example
ALTER SYSTEM KILL SESSION '240,56789' IMMEDIATE;
The IMMEDIATE option requests Oracle to terminate the session as soon as possible.
By identifying the blocking session and terminating it when appropriate, you can quickly resolve database locking issues in Oracle R12 and restore normal application performance.
Comments
Post a Comment