数据库无法打开

[复制链接]
查看11 | 回复3 | 2009-4-28 17:28:37 | 显示全部楼层 |阅读模式
请问下面问题该怎么解决

SQL> alter database open;
alter database open
*
ERROR 位于第 1 行:
ORA-00604: 递归 SQL 层 1 出现错误
ORA-04020: 尝试锁定对象 SYS.CDC_ALTER_CTABLE_BEFORE 时检测到死锁
回复

使用道具 举报

千问 | 2009-4-28 17:28:37 | 显示全部楼层
信息太少,参考一下这个:
Subject:Ora-04020 Deadlocks Most Common Causes
Doc ID:Note:166924.1 Type:TROUBLESHOOTING
Last Revision Date:18-MAY-2004 Status:PUBLISHED

PURPOSE
-------
This article explains the most common scenarios for ORA-04020 Deadlocks and
how to avoid them.

SCOPE & APPLICATION
-------------------
This article is intended for Oracle Support Analysts , Oracle Consultants,
Database Administrators and Application Developers.

Reasons for the ORA-4020
------------------------
An ORA-4020 occurs when a session tries to lock a library object and a deadlock is detected.
It mostly occur during the compilation of packages/triggers/views or the executions of
DDL statements. It sometimes can happen after an software upgrade due to the invalidations
of database objects and the required revalidation of them when you start to use them
(see Note 130409.1).
In general, the first thing to control when you get an ORA-4020 is to see if they are
invalid objects used, and try to recompile/validate them. Secondly, control if DDL commands
are executed by different sessions at the same time, and serialize this processing.
We can distinguish two types of deadlocks:
1. Self Deadlocks
It occur when one session tries to get a lock on a resource that he already has in some way.
Normally, the Oracle engine should detect those situations and should avoid
the signalling of the ORA-04020 to the end-users. When a self deadlock detection occurs,
Oracle generates a trace file in the user_dump_dest. It is only considered as a bug if
an ORA-04020 is signalled to the end-user.
2. Deadlocks between concurrent sessions
The ORA-04020 deadlock error usually occurs when two user processes
cannot complete their transactions because they are trying to access
the same resource.

Self Deadlocks situations
-------------------------
When a self deadlock is detected, a trace file will be generated in the user_dump_dest, e.g.

*** SESSION ID

12.49926) 2001-12-02 10:22:55.364
A deadlock among DDL and parse locks is detected.
This deadlock is usually due to user errors in
the design of an application or from issuing a set
of concurrent statements which can cause a deadlock.
This should not be reported to Oracle Support.
The following information may aid in finding
the errors which cause the deadlock:
ORA-04020: deadlock detected while trying to lock object SCOTT.CHARTEST
--------------------------------------------------------
object waitingwaiting blocking blocking
handle session lock mode session lock mode
---------------- -------- ------------ -------- ----
4269c48 26535dc2ae1d5cX 26535dc2ae2428S
--------------------------------------------------------
---------- DUMP OF WAITING AND BLOCKING LOCKS ----------
--------------------------------------------------------
------------- WAITING LOCK -------------
----------------------------------------
SO: 2ae1d5c, type: 35, owner: 29a8ed8, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=2ae1d5c handle=4269c48 request=X
call pin=0 session pin=0
user=26535dc session=2652d70 count=0 flags=[00] savepoint=0
LIBRARY OBJECT HANDLE: handle=4269c48
name=SCOTT.CHARTEST
hash=93440965 timestamp=12-02-2001 10:22:49
.................

In the previous trace file, we see that the session hold a shared lock (S)
and needs a exclusive lock (X). Therefore, an ora-4020 is generated.
Following examples generate self deadlocks:
1. Truncating a synonym raises an ora-04020 "deadlock detected" rather than an ora-942 "invalid table or view".
The following steps will reproduce this problem :
create synonym emp_syn for scott.emp;
truncate table emp_syn;
The workaround is to avoid using synonyms where they are not
officially supported. (see Note 146926.1)
2. The recompilation of a trigger can sometimes result in an ORA-04020
Sequence of events leading to this problem are:
(1)create table and create trigger on the table.
(2)modify the table by adding partitions or modifying columns, resulting in the invalidation
of the trigger
(3)executing a DML (that requires the trigger to be recompiled at DML time) can generate a self deadlock
ORA-04020 situation.
The workaround consists in recompiling the triggers before executing the DML.
(see Note 108755.1)
3. Compiling circular dependent code
It should normally not be possible to get circular dependent PLSQL/VIEW/SYNONYM/ROLES code
in the database.Errors like "ORA-01731 : circular view definition encountered",
"ORA-01775 : looping chain of synonyms", "ORA-01934 : circular role grant detected"...
should be the result. In some cases, an ORA-4020 can be encountered.
e.g.
create or replace procedure proc1 as
rows integer;
begin
proc2;
end proc1;
/
create or replace procedure proc2 as
rows integer;
begin
proc1;
end proc2;
/
create or replace procedure proc1 as
rows integer;
begin
proc2;
end proc1;
/
gives an ORA-4020.
Workaround: find the circular dependency and remove it
It is also possible to fall on Bug 1612147 if the plsql code is
complex (see Note 156900.1).
If the circular code could get compiled due to whatever reason, it will be
impossible to drop the objects and you will require to contact Oracle Support
to remove them. It is the case if the following script returns rows:
column "dependant name"format a20;
column "dependant owner" format a15;
column "parent owner" format a15;
select d_obj#,
doa.object_name "dependant name",
doa.owner "dependant owner",
doa.status "dep status",
p_obj#,
dob.object_name "parent name",
dob.owner "parent owner"
from dba_objects doa,
dba_objects dob,
dependency$ dp
where (dp.d_obj#, dp.p_obj#)
in (select dpb.p_obj#, dpb.d_obj# from dependency$ dpb)
and dp.d_obj#=doa.object_id
and dp.p_obj#=dob.object_id
and dob.status = 'INVALID';
4. ORA-4020 self deadlock on drop table with a functional index
Dropping a functional index on a table can result in an Ora-4020 deadlock message if the functional index's associated
function references the base table.
Workaround: Drop the functional index(es) first and then drop the table.
5. ORA-04020 when creating functional indexes due to the usage of %TYPE
workaround: avoid using %TYPE in the definition of the function Note 162872.1
6. ALTER TABLE Command Fails Using INDEX ONLINE Option
e.g. alter table emp add primary key (empno) using index online
gives ORA-0420 if there are no unique index on empno
(see Note 153391.1)

Deadlocks between concurrent sessions situations
------------------------------------------------
The most obvious workaround is the serialize the processing. ORA-4020 did occur in following situations:
1. Concurrently analyzing different partitions of the same base object can
fail with an Ora-4020 "deadlock detected".
2. Creating different materialized views against the same base table may result in a Ora-4020 deadlock if executed
concurrently (see Note 103077.1).
3. You can receive an Ora-4020 when jobs insert into a partitioned IOT and another job concurrently tries to move
one of the partitions.

RELATED DOCUMENTS
-----------------
Note 103077.1 ORA-04020 deadlock detected creating MATERIALIZED VIEWS
Note 153391.1 ALTER TABLE Command Fails Using INDEX ONLINE Option
Note 156900.1 ORA-04020 Compiling a Package
Note 162872.1 Creation of Function Based Index Fails With ORA-4020
Note 146926.1 Truncating a Synonym Returns ORA-04020 Deadlock Detected Message
Note 108755.1 ORA-04020 when a trigger is fired
Note 130409.1 ORA-04020 After Upgrade
Bug 1612147Self deadlock ORA-04020 possible compiling PLSQL
Note 131885.1 Analyzing Deadlock Graphs when ORA-4020 occurs
回复

使用道具 举报

千问 | 2009-4-28 17:28:37 | 显示全部楼层
metalink是搜不到什么文章,只有这篇相关点了
回复

使用道具 举报

千问 | 2009-4-28 17:28:37 | 显示全部楼层
问题已解决, 方法如下
-------------------------------------------------------------------------------------------------------------------
Subject:Ora-04020 on Sys.Cdc_alter_ctable_before When Running Catalog.Sql
Doc ID:Note:360509.1 Type:PROBLEM
Last Revision Date:01-FEB-2008 Status:PUBLISHED

Applies to: Oracle Server - Enterprise Edition - Version: 9.2
This problem can occur on any platform.
SymptomsRunning catalog.sql fails with and ORA-4020
ORA-04020: deadlock detected while trying to lock object SYS.CDC_ALTER_CTABLE_BEFORE
.
Verified the issue by the created trace file which shows the following:
ORA-04020: deadlock detected while trying to lock object SYS.CDC_ALTER_CTABLE_BEFORE
object waiting waiting blocking blocking
handle session lock mode session lock mode
-------- -------- -------- ---- -------- -------- ----
39039ccd8 3892cf7f0 38b77a680 X 3892cf7f0 38b470910 X
---------- DUMP OF WAITING AND BLOCKING LOCKS ----------
------------- WAITING LOCK -------------
SO: 38b77a680, type: 51, owner: 38aaf3cc0, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=38b77a680 handle=39039ccd8 request=X
call pin=0 session pin=0
htl=38b77a6f0[38b470980,38b449af8] htb=38b449af8
user=3892cf7f0 session=3892d0d10 count=0 flags=[00] savepoint=5860866
LIBRARY OBJECT HANDLE: handle=39039ccd8
name=SYS.CDC_ALTER_CTABLE_BEFORE
hash=bae60924 timestamp=03-07-2006 10:29:15
namespace=TRGR flags=KGHP/TIM/SML/[02000000]
kkkk-dddd-llll=0000-00ff-00ff lock=X pin=X latch#=3
lwt=39039cd08[38b77a6a0,38b77a6a0] ltm=39039cd18[39039cd18,39039cd18]
pwt=39039cd38[39039cd38,39039cd38] ptm=39039cdc8[39039cdc8,39039cdc8]
ref=39039cce8[39039cce8, 39039cce8] lnd=39039cde0[39039cde0,39039cde0]
LOCK OWNERS:
lock user session count mode flags
-------- -------- -------- ----- ---- ------------------------
38b470910 3892cf7f0 3892d0d10 2 X [00]
LOCK WAITERS:
lock user session count mode
-------- -------- -------- ----- ----
38b77a680 3892cf7f0 3892d0d10 0 X
PIN OWNERS:
pin user session lock count mode mask
-------- -------- -------- -------- ----- ---- ----
38b472560 3892cf7f0 3892d0d10 0 2 X 00ff
LIBRARY OBJECT: object=3923ed1a8
type=TRGR flags=EXS/LOC/BCM/ALT[0025] pflags=NST [101] status=INVL load=0 CauseThis is cause by internal bug 3017048 fixed in 10.1.0.2.
Internal BUG:3017048 - Ora-4020, Functional Index Locking During Invalidation Causing Self-Deadlock

Researching the issue on ora-4020 and SYS.CDC_CREATE_CTABLE_BEFORE lead to BUG 3228083 which was
experiencing similar problems on the same object. This bug was closed as a duplicate of bug 3017048.
Internal BUG:3228083 - Appsst10g:R8:Utlrcmp Error: Ora-04045: Sys.Cdc_Create_Ctable_Before
.

SolutionSet the following in the INIT.ORA then restart the database:
_system_trig_enabled=false
aq_tm_processes=0
job_queue_processes=0
Then rerun CATALOG.SQL.

After creating and running these scripts and the database is ok then restart the database with the parameters taken out of the init.ora.

As an Alternative, if your application is not using CDC, we can disable these triggers as follows:
SQL> conn / as sysdba
SQL> ALTER TRIGGER sys.cdc_alter_ctable_before DISABLE;
SQL> ALTER TRIGGER sys.cdc_create_ctable_after DISABLE;
SQL> ALTER TRIGGER sys.cdc_create_ctable_before DISABLE;
SQL> ALTER TRIGGER sys.cdc_drop_ctable_before DISABLE;
This will also prevent the deadlock from occurring. References
--------------------------------------------------------------------------------
Help us improve our service. Please email us your comments for this document. .
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行