Home » RDBMS Server » Server Administration » Lock output
Lock output [message #556798] Wed, 06 June 2012 11:42 Go to next message
BeefStu
Messages: 208
Registered: October 2011
Senior Member
All:

Can somebody modify this script to show the table name, rowid
which is locked?

In addtion, can somebody please explain the output of script below. In particular, I am trying to understand if there any
active locks.

Thanks to all who answer


set pagesize 85
col username format a10
col osuser format a15
col sid format 9999
col serial format 99999
col type format a2
col request format 9
col lmode format 9
col lmode_desc format a16
col type_desc format a30 wrap
SELECT /*+ FIRST_ROWS ORDERED */ username,
s.osuser osuser , s.sid sid , s.serial# serial, l.lmode lmode ,
decode(L.LMODE,1,'No Lock',
2,'Row Share',
3,'Row Exclusive',
4,'Share',
5,'Share Row Exclusive',
6,'Exclusive','NONE') lmode_desc, l.type type ,
decode(l.type,
'BL','Buffer hash table instance lock',
'CF',' Control file schema global enqueue lock',
'CI','Cross-instance function invocation instance lock',
'CS','Control file schema global enqueue lock',
'CU','Cursor bind lock',
'DF','Data file instance lock',
'DL','Direct loader parallel index create',
'DM','Mount/startup db primary/secondary instance lock',
'DR','Distributed recovery process lock',
'DX','Distributed transaction entry lock',
'FI','SGA open-file information lock',
'FS','File set lock',
'HW','Space management operations on a specific segment lock',
'IN','Instance number lock',
'IR','Instance recovery serialization global enqueue lock',
'IS','Instance state lock',
'IV','Library cache invalidation instance lock',
'JQ','Job queue lock',
'KK','Thread kick lock',
'MB','Master buffer hash table instance lock',
'MM','Mount definition gloabal enqueue lock',
'MR','Media recovery lock',
'PF','Password file lock',
'PI','Parallel operation lock',
'PR','Process startup lock',
'PS','Parallel operation lock',
'RE','USE_ROW_ENQUEUE enforcement lock',
'RT','Redo thread global enqueue lock',
'RW','Row wait enqueue lock',
'SC','System commit number instance lock',
'SH','System commit number high water mark enqueue lock',
'SM','SMON lock',
'SN','Sequence number instance lock',
'SQ','Sequence number enqueue lock',
'SS','Sort segment lock',
'ST','Space transaction enqueue lock',
'SV','Sequence number value lock',
'TA','Generic enqueue lock',
'TD','DDL enqueue lock',
'TE','Extend-segment enqueue lock',
'TM','DML enqueue lock',
'TT','Temporary table enqueue lock',
'TX','Transaction enqueue lock',
'UL','User supplied lock',
'UN','User name lock',
'US','Undo segment DDL lock',
'WL','Being-written redo log instance lock',
'WS','Write-atomic-log-switch global enqueue lock') type_desc ,
request , block
FROM v$lock l, v$session s
WHERE s.sid = l.sid
AND l.type <> 'MR'
AND s.type <> 'BACKGROUND'
ORDER BY username
/

USERNAME   OSUSER            SID SERIAL LMODE LMODE_DESC       TY
---------- --------------- ----- ------ ----- ---------------- --
TYPE_DESC                      REQUEST      BLOCK
------------------------------ ------- ----------
D156293    N247897          1266   1165     3 Row Exclusive    TO
                                     0          0

D156293    N247897          1266   1165     6 Exclusive        TX
Transaction enqueue lock             0          0

ESTAR      a_estara         2038    148     3 Row Exclusive    TO
                                     0          0


Re: Lock output [message #556806 is a reply to message #556798] Wed, 06 June 2012 13:06 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
do you suffer from Compulsive Tuning Disorder?

What Oracle error code & message needs to be resolved?

Oracle is designed to use locks to maintain data integrity.

so what problem do you think needs to be resolved?
Lock output [message #556811 is a reply to message #556806] Wed, 06 June 2012 14:18 Go to previous messageGo to next message
BeefStu
Messages: 208
Registered: October 2011
Senior Member
There is no specific error. I had a user complain that a query was taking a very long time to finish when the the same query (different values for the bind variables) ran a few hours earlier finished in acceptable amount of time.

I did not see any blocking sessions nor long operations and was trying to see if maybe a locking issue was the cause of the problem.

I am in the process of gathering and comparing explain plans for both the queries.
Re: Lock output [message #556812 is a reply to message #556811] Wed, 06 June 2012 14:23 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
> was trying to see if maybe a locking issue was the cause of the problem.
real locks throw error when conflict occurs.
Re: Lock output [message #556813 is a reply to message #556812] Wed, 06 June 2012 14:34 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
SQL_TRACE can show where time is actually being spent.

post results from following SQL

SELECT * FROM V$VERSION;

does problem SQL utilize bind variables?
Re: Lock output [message #556821 is a reply to message #556813] Wed, 06 June 2012 15:04 Go to previous messageGo to next message
BeefStu
Messages: 208
Registered: October 2011
Senior Member

SQL> SELECT * FROM V$VERSION;


BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE    10.2.0.5.0      Production
TNS for Solaris: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production




Yes problem happens with SQL using bind variables.

I will set SQL_TRACE and see what I can find. Thanks for the suggestions.
Re: Lock output [message #556822 is a reply to message #556821] Wed, 06 June 2012 15:06 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Yes problem happens with SQL using bind variables.

http://www.lmgtfy.com/?q=oracle+bind+variable+peeking
Re: Lock output [message #556841 is a reply to message #556811] Wed, 06 June 2012 23:21 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
Can somebody modify this script to show the table name, rowid
which is locked?


You don't the rows that are locked, you only know the row that you are waiting on (see v$session).

Regards
Michel
Previous Topic: Want To tablespace Autoextend OFF?
Next Topic: Stale Stats
Goto Forum:
  


Current Time: Fri Nov 29 02:30:38 CST 2024