彻底搞清楚library cache lock的成因和解决方法(一)[1]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 lunar2000 的 blog

问题描述:
接到应用人员的报告,说是在任何对表csnoz629926699966的操作都会hang,包括desc csnoz629926699966,
例如:

ora9i@cs_dc02:/ora9i > sqlplus pubuser/pubuser

sql*plus: release 9.2.0.4.0 - production on mon jan 10 10:11:06 2005

copyright (c) 1982, 2002, oracle corporation.  all rights reserved.


connected to:
oracle9i enterprise edition release 9.2.0.4.0 - 64bit production
with the partitioning and real application clusters options
jserver release 9.2.0.4.0 - production

sql> conn pubuser/pubuser
connected.
sql> desc csnoz629926699966

。。。

这个进程 hang 了

。。。

 

询问了一下之前有无特别的操作,业务人员说很久以前执行了脚本,但是该教本运行很久都没有结果,然后他就退出了会话,再之后,就出现了上面的情况。脚本内容如下:
$ cat csnoz629926699966.sh
#!/bin/sh
sqlplus pubuser/pubuser@csmisc << eof  #use your username/password

create table csnoz629926699966 as select * from csnoz62992266cs
where mid not in ( select mid from pubuser.subscription_bak_200412@newdb where servid='020999011964' and status in ('a','b','s'));

exit;
$
$
$
$

解决过程:
ora9i@cs_dc02:/ora9i > sqlplus "/ as sysdba"

sql*plus: release 9.2.0.4.0 - production on mon jan 10 10:19:13 2005

copyright (c) 1982, 2002, oracle corporation.  all rights reserved.


connected to:
oracle9i enterprise edition release 9.2.0.4.0 - 64bit production
with the partitioning and real application clusters options
jserver release 9.2.0.4.0 - production

sql> select * from v$lock where block=1;

no rows selected

sql> /

no rows selected

sql> /

no rows selected

sql>
我们看到目前没有锁的信息

sql> select xidusn, object_id, session_id, locked_mode from v$locked_object;

。。。   

 xidusn  object_id session_id locked_mode
---------- ---------- ---------- -----------
        14         18         37           3

。。。

sql> /

。。。   

 xidusn  object_id session_id locked_mode
---------- ---------- ---------- -----------
        14         18         37           3

。。。

sql> /

。。。   

 xidusn  object_id session_id locked_mode
---------- ---------- ---------- -----------
        14         18         37           3

。。。

sql>
查找 v$locked_object,我们发现了一个可疑的会话,sid 37:

sql> select object_name,owner,object_type from dba_objects where object_id=18;

。。。 。。。

object_name                    owner                          object_type
------------------------------ ------------------------------ ------------------
obj$                           sys                            table

 

。。。 。。。

sql>

奇怪怎么一直有这个锁??
初步猜测是由于sid为37的会话执行了上面的ddl语句,并在语句未完成前异常退出,
造成了所有访问那个(ddl语句中涉及到的)对象的进程都hang了。


接下来我们看看等待事件:

本文关键:彻底搞清楚library cache lock的成因和解决方法(一)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top