Skip to Main Content
  • Questions
  • INACTIVE session is blocking active session

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Akshay.

Asked: November 12, 2017 - 4:51 pm UTC

Last updated: July 08, 2021 - 3:51 am UTC

Version: 11g

Viewed 10K+ times! This question is

You Asked

DBA is throwing information as follows
06112017:11:00:09 WELOPP@n1pv97/46581 (Session=('300,19867')Status=INACTIVE sqlid=>) blocking WELOPP@n1pv97/45876 (Session=('1803,10683')
Status=ACTIVE sqlid=fp5x2quh0zpqk) for the last 91850 seconds.

06112017:11:00:09 WELOPP@n1pv97/46581 (Session=('300,19867')Status=INACTIVE sqlid=>) blocking WELOPP@n1pv97/59864 (Session=('843,58185')
Status=ACTIVE sqlid=fp5x2quh0zpqk) for the last 5388 seconds.

As stated above it says INACTIVE session is blocking active session. DBA is giving only this much information.
Now I want to understand what sql is blocking the sql from active session.
Is there any way to find out?
If not, then what is impact of above situation on application?
how can we mitigate this locking situation?

and Connor said...

Not really because it is not a *SQL* that is blocking your active session, it is a *lock*.

For example - in a 1 row table:

Session 1 does:

- delete the row
- insert a new row
- updates that row
- runs 500 queries against other tables
- goes to lunch

Session 2 comes along, tries to do something with that row and gets blocked.... it not really an SQL that has blocked them - it could one of any of the first three above, but they could have been run hours ago.

What you *can* work out is what *locks* the session has by examining v$lock. For example, a basic script I'll often use is:

--
-- an example locked row
--
SQL> delete from t_target where rownum = 1;

1 row deleted.

SQL> SELECT  /*+ ORDERED */
  2          s.username,
  3          s.osuser,
  4          S.SID,
  5          L.TYPE,
  6          L.ID1,
  7          o.object_name,
  8          DECODE(L.LMODE, 0, 'NONE', 1, 'NULL', 2, 'SS', 3, 'RX', 4, 'S', 5, 'SRX', 6, 'X', '?') holding,
  9          DECODE(L.REQUEST, 0, 'NONE', 1, 'NULL', 2, 'SS', 3, 'RX', 4, 'S', 5, 'SRX', 6, 'X', '?') wanting,
 10          l.ctime how_long,
 11          decode(l.block,0,null,2,null,'YES') is_blocking
 12  FROM V$SESSION S, V$LOCK L, sys.dba_objects o
 13  WHERE L.SID=S.SID
 14  AND S.USERNAME is not null
 15  and l.type != 'AE'
 16  and l.id1 = o.object_id
 17  /

USERNAME             OSUSER                                SID TY        ID1 OBJECT_NAME                              HOLD WANT   HOW_LONG IS_
-------------------- ------------------------------ ---------- -- ---------- ---------------------------------------- ---- ---- ---------- ---
MCDONAC              XPS13\hamcdc                           23 TM     166581 T_TARGET                                 RX   NONE         76

2 rows selected.


Here are some mitigation strategies







You can also use Resource Manager to terminate a session that is inactive but is blocking an active resource.

See

https://docs.oracle.com/database/122/ADMIN/managing-resources-with-oracle-database-resource-manager.htm#ADMIN11862

for details on the MAX_IDLE_BLOCKER_TIME directive.

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Gh, November 13, 2017 - 8:44 am UTC

".... it not really an SQL that has blocked them - it could one of any of the first three above,"

Could you pls remind what are "the first three above " and say why they are not SQL?

I am confused.
Connor McDonald
November 13, 2017 - 3:22 pm UTC

- delete the row <<==== 1
- insert a new row <<==== 2
- updates that row <<==== 3
- runs 500 queries against other tables
- goes to lunch

Informative

Akshay Kumbhar, November 13, 2017 - 10:30 am UTC

Thanks Connor McDonald. Got much more info that I could get via googling
Connor McDonald
November 13, 2017 - 3:21 pm UTC

Glad to help

Commit Statement

Mark Staples, July 07, 2021 - 3:57 pm UTC

Tom, if the user commits the transaction prior to going to lunch would there still be a problem? I have some update jobs that are not running until we kill some sessions. These sessions are inactive and according to our DBAs don't have any locks or blocks. I am confused why they would hold up another session.
Connor McDonald
July 08, 2021 - 3:51 am UTC

These sessions are inactive and according to our DBAs don't have any locks or blocks. I am confused why they would hold up another session.

That sounds dubious.

When your update gets stuck, query v$session and look at the columns

BLOCKING_SESSION_STATUS
BLOCKING_INSTANCE
BLOCKING_SESSION
EVENT

That is where the answer will lie

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database