关于alter table xxx enable table lock

[复制链接]
查看11 | 回复9 | 2013-2-25 14:51:24 | 显示全部楼层 |阅读模式
单机环境,disable table lock 后无法 enable table lock
各位看看是什么原因
--------------
连接到:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.7.0 - Production
SQL> create table test_d tablespace tbs_cdr_1 as select * from all_tables;
表已创建。
SQL> alter table test_d disable table lock;
表已更改。
SQL> drop table test_d;
drop table test_d
*
第 1 行出现错误:
ORA-00069: cannot acquire lock -- table locks disabled for TEST_D

SQL> alter table test_d enable table lock;--此时可以确定该表没有任何lock
alter table test_d enable table lock
*
第 1 行出现错误:
ORA-00054: resource busy and acquire with NOWAIT specified

SQL>
SQL>
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
在10.2.0.3环境下模拟了一下你的场景。
sec@ora10g> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE10.2.0.3.0Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
sec@ora10g> create table test_d as select * from all_tables;
Table created.
sec@ora10g> alter table test_d disable table lock;
Table altered.
sec@ora10g> drop table test_d;
drop table test_d
*
ERROR at line 1:
ORA-00069: cannot acquire lock -- table locks disabled for TEST_D

sec@ora10g> alter table test_d enable table lock;
Table altered.
sec@ora10g> drop table test_d;
Table dropped.

请确定您最后执行的语句时,是否有其他的session正在使用这个表。
secooler
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
10g我也测试成功了
但是9.2.0.7 测试不通过
我可以确定没有任何锁
v$locked_object 是空的
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
MOS上有一个bug文章:Bug 3093080 - ALTER TABLE ENABLE TABLE LOCK can cause a deadlock [ID 3093080.8]

BTW:您使用这种方法的目的是什么呢?
secooler
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
是这样
我有一个测试库,很多人用,需要备份点数据,不想让别人删掉我备份的数据。
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
上次10.2.0.4+linux上enable table lock时也碰到问题了,ora-600 kcbgcur_9
看来这个东东不是很健壮
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
原帖由 xGss2000 于 2010-1-25 13:43 发表
是这样
我有一个测试库,很多人用,需要备份点数据,不想让别人删掉我备份的数据。


既然不希望其他人修改您需要备份的信息,是否可以考虑使用悲观锁方法select * from t for update;
极端点可以考虑重启数据库但不起监听(前提是测试库)。
secooler
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
Can't reproduce:
SQL> create table test_d as select * from all_tables;
Table created.
SQL> alter table test_d disable table lock;
Table altered.
SQL> drop table test_d;
drop table test_d
*
ERROR at line 1:
ORA-00069: cannot acquire lock -- table locks disabled for TEST_D

SQL> alter table test_d enable table lock;
Table altered.
SQL> select * from v$version where rownum = 1;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
Yong Huang
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
select * from v$mystat; -- 获取到sid 为72
alter table test_d enable table lock; -- 会等待60秒整,然后报 resourcebusy
select * from v$lock where (id1,id2) in (select id1,id2 from v$lock where sid=72)and block=1;-- 会查到一个tx锁阻止了alter命令
ADDR
KADDR
SID
TYPE
ID1
ID2
LMODE
REQUEST
CTIME
BLOCK
00000005AE533BF8
00000005AE533D70
32
TX
65549
401416
6
0
1790721
1

我查了下这个sid=32的进程 是一个 weblogic前台进程,不可对我这张表持有锁的

求解
[ 本帖最后由 xGss2000 于 2010-1-26 13:40 编辑 ]
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
How are you so sure "不可对我这张表持有锁的"? I bet you can find its transaction in v$transaction.
Why not try to reproduce this with SQL trace turned on for that Weblogic session so we know what SQL it runs along the way? There must be some DML in the middle of it.
Yong Huang
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行