LibraryCacheLock的解决

昨晚业务系统导入资料并重建索引时一个会话突然停滞不前,用TOAD一看,一直在等待LibraryCacheLock。TOAD、OEM中都看不到此锁,会话每三秒启动一次,但每次都是等待这个锁。显然,这和数据字典有关,应该是一个索引的数据字典中的记录被锁住了,导致无法重建。可是杀光了其他ACTIVE的会话,问题仍然没有得到 解决,看来是某一个被杀死的会话持有该锁,而会话尚未回滚完全,进程仍然吊死着。现在的问题就是找这个会话了。
首先想到的文档就是9iDatabaseReference了,找到附录A,说明如下:

Thiseventcontrolstheconcurrencybetweenclientsofthelibrarycache.Itacquiresalockontheobjecthandlesothateither:

Oneclientcanpreventotherclientsfromaccessingthesameobject

Theclientcanmaintainadependencyforalongtime(forexample,nootherclientcanchangetheobject)

Thislockisalsoobtainedtolocateanobjectinthelibrarycache.

WaitTime:3seconds(1secondforPMON)

Parameters:

handleaddress

Addressoftheobjectbeingloaded

lockaddress

Addressoftheloadlockbeingused.Thisisnotthesamethingasalatchoranenqueue,itisaStateObject.

mode

Indicatesthedatapiecesoftheobjectwhichneedtobeloaded

namespace

See"namespace"


几乎等于什么都没说,不过lockaddress应该会有点用处。
转而上网搜索 解决方案,终于找到一篇metalink上的文档:
DocID:
Note:122793.1
Subject: HOWTOFINDTHESESSIONHOLDINGALIBRARYCACHELOCK
Type: BULLETIN
Status: PUBLISHED
 ContentType: TEXT/PLAIN
CreationDate: 23-OCT-2000
LastRevisionDate: 17-JUL-2002

PURPOSE
-------
 
 Insomesituationsitmayhappenyoursessionis'hanging'andisawaitingfor 
 a'Librarycachelock'.Thisdocumentdescribeshowtofindthesessionthat 
 infacthasthelockyouarewaitingfor.
 
 
SCOPE&APPLICATION
-------------------
 
Supportanalysts,dba's,..
 
 
HOWTOFINDTHESESSIONHOLDINGAALIBRARYCACHELOCK
------------------------------------------------------
 
 Commonsituations:
 
 *aDMLoperationthatishangingbecausethetablewhichisaccessediscurrently 
  undergoingchanges(ALTERTABLE).Thismaytakequitealongtimedependingon 
  thesizeofthetableandthetypeofthemodification 
  (e.g.ALTERTABLExMODIFY(col1CHAR(200)onthousandsofrecords). 
 
*ThecompilationofpackagewillhangonLibraryCacheLockandLibraryCachePin 
 ifsomeusersareexecutinganyProcedure/Functiondefinedinthesamepackage. 
 
 InthefirstsituationtheV$LOCKviewwillshowthatthesessiondoingthe 
 'ALTERTABLE'hasanexclusiveDMLenqueuelockonthetableobject(LMODE=6, 
 TYPE=TMandID1istheOBJECT_IDofthetable).Thewaitingsessionhoweverdoes 
 notshowupinV$LOCKyetsoinanenvironmentwithalotofconcurrentsessions 
 theV$LOCKinformationisinsufficienttotrackdowntheculpritblockingyour 
 operation.
 
METHOD1:SYSTEMSTATEANALYSIS
------------------------------
 
 Onewayoffindingthesessionblockingyouistoanalyzethesystemstatedump.
 Usingthesystemstateeventonecancreateatracefilecontainingdetailed 
 informationoneveryOracleprocess.Thisinformationincludesalltheresources
 held&requestedbyaspecificprocess. 1

你可能感兴趣的:(数据库)