Skip to Main Content
  • Questions
  • V$session entry is missing for locked session. When the same is present in v$locked_object

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Tannu.

Asked: June 10, 2020 - 6:34 am UTC

Last updated: June 13, 2020 - 9:38 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hi Tom,

I follow your post whenever I am in doubt. I almost everytime find solution my problem. Your posts are very helpful. I am stumbled upon an issue recently and trying to find solution for it. Hence writing to you. Below is the description.

Yesterday even after updating a table
1. First i update my table but did not commit or rollback. Update employee set id=1 where id=2;
2. I checked v$locked_object i was able to see entry for that table. I copied the session id.
3. Using that session id i can see entry in v$lock table but there are 3 entry one entry for my locked object with type TM and there are two other entry with AE and TX.
4. Using this session id i looked into v$session and copied the sql id and used the same in v$sql. But the sql is "select * from v$session where sid=37". Not that update statement I executed first time.
5. Then i check v$sqlarea and searched the update statement in the text. And got the sql id
6. Using that sql id i again searched in v$session but no entry again.

It will be great help if you can explain this and how to check entry in v$session as i wanted to check row_wait_row# and using this wanted to get row id of the same using dbms_rowid.rowid_create

Can you please explain this? Thank you in advance.

Tanusree

and Connor said...

*While* I am running a SQL, it appears as the SQL_ID in V$SESSION.

eg

Session 1: select count(*) from my_big_table
Session 2: select sql_id from v$session where sid = [session 1]

and you would see the SQL_ID for the running SQL.

But the moment that query (or whatever command it was doing) *completes*, the SQL_ID column in V$SESSION will be null, because it is not running anything right now. (Or it could be a brand new SQL_ID because it has moved onto running something else).

But *while* another session is waiting, you can what it is *trying* to get from V$SESSION, eg

Session 1:

SQL> create table t as select * from dual;

Table created.

SQL> delete from t;

1 row deleted.


Session 2:


SQL> delete from t;

[stuck]




I can then look at what session 2 is stuck on

SQL> select * from v$session where sid = 127
  2  @pr
==============================
SADDR                         : 00007FFCD2C230F8
SID                           : 127
SERIAL#                       : 25696
AUDSID                        : 1127778
PADDR                         : 00007FFCD25F2DA0
USER#                         : 107
USERNAME                      : MCDONAC
COMMAND                       : 7
OWNERID                       : 2147483644
TADDR                         : 00007FFCC8AD3B60
LOCKWAIT                      : 00007FFCCD0D10F0
STATUS                        : ACTIVE
SERVER                        : DEDICATED
SCHEMA#                       : 107
SCHEMANAME                    : MCDONAC
OSUSER                        : GTX\hamcdc
PROCESS                       : 25868:16988
MACHINE                       : WORKGROUP\GTX
PORT                          : 60424
TERMINAL                      : GTX
PROGRAM                       : sqlplus.exe
TYPE                          : USER
SQL_ADDRESS                   : 00007FFCAD302680
SQL_HASH_VALUE                : 1063131497
SQL_ID                        : 1hws8f0zpw6b9
SQL_CHILD_NUMBER              : 0
SQL_EXEC_START                : 11-JUN-20
SQL_EXEC_ID                   : 16777217
PREV_SQL_ADDR                 : 00007FFCA6E19D18
PREV_HASH_VALUE               : 3928840931
PREV_SQL_ID                   : 0qq0c4bp2uqr3
PREV_CHILD_NUMBER             : 0
PREV_EXEC_START               : 11-JUN-20
PREV_EXEC_ID                  : 16777230
PLSQL_ENTRY_OBJECT_ID         :
PLSQL_ENTRY_SUBPROGRAM_ID     :
PLSQL_OBJECT_ID               :
PLSQL_SUBPROGRAM_ID           :
MODULE                        : SQL*Plus
MODULE_HASH                   : 3669949024
ACTION                        :
ACTION_HASH                   : 0
CLIENT_INFO                   :
FIXED_TABLE_SEQUENCE          : 386777
===>>  ROW_WAIT_OBJ#                 : 91121
===>>  ROW_WAIT_FILE#                : 64
===>>  ROW_WAIT_BLOCK#               : 59299
===>>  ROW_WAIT_ROW#                 : 0
TOP_LEVEL_CALL#               : 94
LOGON_TIME                    : 11-JUN-20
LAST_CALL_ET                  : 21
PDML_ENABLED                  : NO
FAILOVER_TYPE                 : NONE
FAILOVER_METHOD               : NONE
FAILED_OVER                   : NO
RESOURCE_CONSUMER_GROUP       : OTHER_GROUPS
PDML_STATUS                   : DISABLED
PDDL_STATUS                   : ENABLED
PQ_STATUS                     : ENABLED
CURRENT_QUEUE_DURATION        : 0
CLIENT_IDENTIFIER             :
BLOCKING_SESSION_STATUS       : VALID
BLOCKING_INSTANCE             : 1
BLOCKING_SESSION              : 369
FINAL_BLOCKING_SESSION_STATUS : VALID
FINAL_BLOCKING_INSTANCE       : 1
FINAL_BLOCKING_SESSION        : 369
SEQ#                          : 57
EVENT#                        : 307
EVENT                         : enq: TX - row lock contention
P1TEXT                        : name|mode
P1                            : 1415053318
P1RAW                         : 0000000054580006
P2TEXT                        : usn<<16 | slot
P2                            : 524301
P2RAW                         : 000000000008000D
P3TEXT                        : sequence
P3                            : 19170
P3RAW                         : 0000000000004AE2
WAIT_CLASS_ID                 : 4217450380
WAIT_CLASS#                   : 1
WAIT_CLASS                    : Application
WAIT_TIME                     : 0
SECONDS_IN_WAIT               : 22
STATE                         : WAITING
WAIT_TIME_MICRO               : 21772035
TIME_REMAINING_MICRO          : -1
TIME_SINCE_LAST_WAIT_MICRO    : 0
SERVICE_NAME                  : pdb1
SQL_TRACE                     : DISABLED
SQL_TRACE_WAITS               : FALSE
SQL_TRACE_BINDS               : FALSE
SQL_TRACE_PLAN_STATS          : FIRST EXEC
SESSION_EDITION_ID            : 134
CREATOR_ADDR                  : 00007FFCD25F2DA0
CREATOR_SERIAL#               : 92
ECID                          :
SQL_TRANSLATION_PROFILE_ID    : 0
PGA_TUNABLE_MEM               : 0
SHARD_DDL_STATUS              : DISABLED
CON_ID                        : 3
EXTERNAL_NAME                 : GTX\hamcdc
PLSQL_DEBUGGER_CONNECTED      : FALSE

PL/SQL procedure successfully completed.


But I am not sure what you mean by "delete a rowid". Because even if you work out a rowid from the 4 columns above, you can't delete it - because you would just get blocked as well. You need to kill the session *holding* the lock.

Rating

  (1 rating)

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

Comments

Very Helpful

Tanusree, June 11, 2020 - 8:42 am UTC

Thanks for the reply. It really helped.
Connor McDonald
June 13, 2020 - 9:38 am UTC

glad we could help

More to Explore

Administration

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