标签:
在做数据迁移的过程中,我们会面临两种常见的hang住场景:
1.表不能修改加字段,不能增大长度。
2.存储过程不能覆盖。
场景1:为表添加字段hang住的处理alter system kill session ‘8,16603‘;--干掉session,注意的是如果是RAC,视图都要加上G,如v$lock,是GV$lock。
场景2:存储过程不能覆盖
session1 新建并执行:
create or replace procedure p_test_pin
as
begin
dbms_lock.sleep(3000);
end;
call p_test_pin();
session2 覆盖:
create or replace procedure p_test_pin()
begin
dbms_lock.sleep(1000);
end;
方法1,找到所在会话和进程id,如果是RAC则都要查GV:
x$kglpn library cache pin信息
x$kglob library cache object信息
SQL> SELECT s.sid,s.SERIAL#, kglpnmod "Mode", kglpnreq "Req", SPID "OS Process"
FROM v$session_wait w, sys.x$kglpn p, v$session s, v$process o
WHERE p.kglpnuse = s.saddr
AND kglpnhdl = w.p1raw
and w.event like ‘%library cache pin%‘
and s.paddr = o.addr;
SID SERIAL# Mode Req OS Process
---------- ---------- ---------- ---------- -------------------
8 17376 2 0 22118
133 4430 0 3 22120
先杀掉会话:alter system kill session ‘8,17376‘;
如果会话杀不掉,则只有从操作系统层面杀进程:kill -9 22118
方法2,找到持有者:
SQL> SELECT sid Holder_sid,
SERIAL# hold_SERIAL,
KGLPNUSE Sesion,
KGLPNMOD Held,
KGLPNREQ Req
FROM sys.x$kglpn, v$session
WHERE KGLPNHDL IN (SELECT p1raw
FROM v$session_wait
WHERE event LIKE ‘library cache pin%‘)
AND KGLPNMOD <> 0
AND v$session.saddr = x$kglpn.kglpnuse;
HOLDER_SID HOLD_SERIAL SESION HELD REQ
---------- ----------- ---------------- ---------- ----------
8 17376 0000000127618FA8 2 0
找到持有者在执行什么SQL
SQL> SELECT sid, sql_text
FROM v$session, v$sqlarea
WHERE v$session.sql_address = v$sqlarea.address AND sid =8;
SID SQL_TEXT
------ -----------
8 call p_test_pin()
标签:
原文地址:http://blog.csdn.net/stevendbaguo/article/details/45818181