只读用户造成的阻塞
作者 :OoNiceDream【转载时请务必以超链接形式标明文章原始出处和作者信息】
链接:http://www.dbaroad.me/archives/2009/06/about_select_for_update.html
链接:http://www.dbaroad.me/archives/2009/06/about_select_for_update.html
系统出现好几百个enq: TX - row lock contention,MODE为6,检查发现是一个会话在执行select…for update并且不带where条件,阻塞了其它会话,检查用户的权限发现,这个用户只有Select该表的权限。这才发现原来没有update表的权限,也可以执行select…for update,并持有锁。
创建用户,授予只读权限:
SQL> create user rockey identified by rockey; User created. SQL> grant create session to rockey; Grant succeeded. SQL> grant select on sys.test_update to rockey; Grant succeeded. |
会话一:执行select…for update
SQL> conn rockey/rockey Connected. SQL> select * from sys.test_update for update; ID ---------- 1 |
会话二:检查锁的情况
SQL> select sid,username from v$session 2 where username='ROCKEY'; SID USERNAME ---------- ------------------------------ 502 ROCKEY SQL> select sid,type,id1,id2,lmode,request,ctime,block 2 from v$lock where type in ('TX','TM'); SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK ------- -- ---------- ---------- ------- ---------- ---------- ---------- 502 TM 94435 0 3 0 23 0 502 TX 655390 131846 6 0 23 0 |
会话三:执行update
SQL> update test_update set id=2 where id=1; |
被堵住了,无返回。
会话二:检查锁的情况
SQL> select sid,type,id1,id2,lmode,request,ctime,block 2 from v$lock where type in ('TX','TM') 3 order by sid,id1; SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK ------- -- ---------- ---------- ------- ---------- ---------- ---------- 502 TM 94435 0 3 0 114 0 502 TX 655390 131846 6 0 114 1 511 TM 94435 0 3 0 54 0 511 TX 655390 131846 0 6 54 0 |
会话511被堵住了,这就是只读用户,也能阻塞其它会话了,汗。
— The End —
关键字: 故障案例


站内搜索