Chinaunix首页 | 论坛 | 博客
  • 博客访问: 278577
  • 博文数量: 27
  • 博客积分: 368
  • 博客等级: 一等列兵
  • 技术积分: 491
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-09 21:35
个人简介

再出发..

文章分类

全部博文(27)

文章存档

2018年(1)

2014年(6)

2013年(5)

2012年(15)

我的朋友

分类: Oracle

2013-01-18 16:48:28

    中午一开发说更新了一个package body里几个procedure之后编译一直不成功,PL/SQL Developer无响应不报错,没碰到过这种问题,看了alert也没有发现异常,检查了代码没有问题,猜测是不是有可能procedure中涉及到的对象被锁从而导致编译不成功,查询v$lock没有看到blocker,然后编译的那个会话就报错了

ORA-04021: timeout occurred while waiting to lock object


[oracle@ASM ~]$ oerr ora 04021
04021, 00000, "timeout occurred while waiting to lock object %s%s%s%s%s"
// *Cause:  While waiting to lock a library object, a timeout occurred.
// *Action: Retry the operation later.


    google了一把,一般ORA-04021是因为这个包正在被其他会话调用,编译时申请不到library lock导致的,通过dba_ddl_lock 找到调用这个包的会话kill之后据能够正常编译,按照这个方法问题得到解决。


下面把这个错误重现了一下:

SCOTT@ora11g> create or replace procedure p1 as 
  2  begin
  3  while true loop
  4  null;
  5  end loop;
  6  end;
  7  /


Procedure created.

SYS@ora11g> alter procedure scott.p1 compile;


Procedure altered.

SCOTT@ora11g> exec p1


SYS@ora11g> alter procedure scott.p1 compile;
alter procedure scott.p1 compile
*
ERROR at line 1:
ORA-04021: timeout occurred while waiting to lock object

SYS@ora11g> select * from dba_ddl_locks where name='P1';


SESSION_ID OWNER NAME  TYPE                                     MODE_HELD MODE_REQU
---------- ----- ----- ---------------------------------------- --------- ---------
        21 SCOTT P1    Table/Procedure/Type                     Null      None

SYS@ora11g> select sid,serial# from v$session where sid=21;


       SID    SERIAL#
---------- ----------
        21        149

SYS@ora11g> alter system kill session '21,149';


System altered.

SCOTT@ora11g> exec p1
BEGIN p1; END;


*
ERROR at line 1:
ORA-00028: your session has been killed
ORA-00028: your session has been killed


SCOTT@ora11g> 

SYS@ora11g> alter procedure scott.p1 compile;


Procedure altered.


阅读(16953) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~