用户A履行删除,但是没有提交。
SQL> delete from test where object_id<10;
已删除8行。
用户B履行删除或更新id<10的记录,则被阻塞。
SQL> update test set flag=’N’ where object_id<10;
遇到这类阻塞,首先需要肯定问题。可使用以下脚本。
select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;
结果以下:
USERNAME SID SERIAL# LOGON_TIME
—————————— ———- ———- ————–
LIHUILIN 14 87 09⑴1月⑴3
LIHUILIN 139 655 09⑴1月⑴3
—————————— ———- ———- ————–
LIHUILIN 14 87 09⑴1月⑴3
LIHUILIN 139 655 09⑴1月⑴3
或使用
select
(select username from v$session where sid=a.sid) blocker,
a.sid,’ is blocking ‘,
(select username from v$session where sid=b.sid) blockee,
b.sid
from v$lock a,v$lock b
where a.block=1 and b.request>0 and a.id1=b.id1 and a.id2=b.id2;
(select username from v$session where sid=a.sid) blocker,
a.sid,’ is blocking ‘,
(select username from v$session where sid=b.sid) blockee,
b.sid
from v$lock a,v$lock b
where a.block=1 and b.request>0 and a.id1=b.id1 and a.id2=b.id2;
结果以下:
BLOCKER SID ‘ISBLOCKING’ BLOCKEE SID
—————————— ———- ————- —————————— ———-
LIHUILIN 14 is blocking LIHUILIN 139
—————————— ———- ————- —————————— ———-
LIHUILIN 14 is blocking LIHUILIN 139
Kill引发阻塞的Session
select ‘alter system kill session ”’||sid||’,’||serial#||”’;’ cmd from v$session where username=’LIHUILIN’ and sid=14;
结果以下:
CMD
—————————————–
alter system kill session ‘14,87’;
—————————————–
alter system kill session ‘14,87’;
最后履行alter system命令,阻塞消除。
本文来源:https://www.yuntue.com/post/152256.html | 云服务器网,转载请注明出处!

微信扫一扫打赏
支付宝扫一扫打赏