Hi all,
I am using following script to see locks in the DB. Do you see any problems with it?
======================== cut here =====================
connect / as sysdba
set linesize 200 feedback off heading on pagesize 100
column sid format a9
column res heading 'Resource Type' format a15 trunc
column id1 format 9999999 noprint
column id2 format 9999999 noprint
column lmode heading 'Lock Held' format a14
column request heading 'Lock Req.' format a14
column serial# format 99999
column username format a10
column terminal heading Term format a8
column table_name format a20 trunc
column owner format a10
column inst_id format a5
select --+ no_merge(l) no_merge(s)
(select instance_name
from sys.gv_$instance
where instance_number = l.inst_id) inst_id,
l.sid || ',' || s.serial# sid,
s.username,
replace(s.terminal,'WTS-') terminal,
decode(l.type,
'RW','RW-Row Wait Enq',
'TM','TM-DML Enq',
'TX','TX-Trans Enq',
'UL','UL-User',l.type||'-System') res,
t.name table_name,u.name owner,
l.id1,l.id2,
decode(l.lmode,1,'No Lock',
2,'Row Share',
3,'Row Excl',
4,'Share',
5,'Shr Row Excl',
6,'Excl',null) lmode,
decode(l.request,1,'No Lock',
2,'Row Share',
3,'Row Excl',
4,'Share',
5,'Shr Row Excl',
6,'Excl',null) request
from sys.gv_$lock l, sys.gv_$session s, sys.user$ u,sys.obj$ t
where l.sid = s.sid
and s.type != 'BACKGROUND'
and t.obj# = l.id1
and u.user# = t.owner#
and l.inst_id = s.inst_id
/
prompt
set feedback on
prompt
exit
======================== cut here =====================
Btu here is the problem ... once in a while (aka many times a day) when we run this script, we see objects as locked by some user which should NEVER be even accessed. We have one schema that deals with out affiliates, and it is practically independent of other schema in the database. Still sometimes we see objects within the affiliate schema beign accesses by other users who have nothing to do (or the code they execute has nothing to do) with the objects displayed in the list.
One peculier thing I have noted, is affiliate schema used private synonyms and the objects listed in the lock scripts are _always_ private synonyms pointing to objects in the affiliate schema and the private synonym belongs to the user who is _not_ the locking user.
e.g.
ABC1 47,820 BROWNBRE BRS02 TX-Trans Enq SYSTEM_NETWORK_HIST MURPHYM Excl
here locking user ius brownbre locking system_network_hist owned by murphym. Actually the table is owned by affiliate and murphym has a private synonym to the table.
Any clues? DB is 9202 RAC.
TIA
Raj
--------------------------------------------------------------------------------
Rajendra dot Jamadagni at nospamespn dot com
All Views expressed in this email are strictly personal.
QOTD: Any clod can have facts, having an opinion is an art !
********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************2
