Rumah >pangkalan data >tutorial mysql >Oracle数据库编译存储过程假死问题
Oracle编译存储过程假死问题
这种情况下如果强行终止存储过程编译,再次Recompile存储过程会发现还是挂死的,这个主要是由于强行终止后会话为INACTIVE状态,但是该会话却没有被真正的释放。使用如下语句查询出挂起的会话:
SELECT V.OSUSER, V.PROCESS, V.PROGRAM, v.MACHINE, V.TERMINAL, V.MODULE, V.USERNAME, V.STATUS, V.SID, V.SERIAL#, 'alter system kill session '''||V.sid||','|| V.SERIAL#||''';' as KILL_SESSION, V.PADDR
FROM V$SESSION V
WHERE V.USERNAME LIKE '%USERNAME%'
AND V.PROGRAM like 'PlSqlDev%'
AND V.OSUSER LIKE '%%'
AND V.STATUS='INACTIVE';
将结果中KILL_SESSION一列复制,在sqlplus下执行,杀掉这些未释放的会话,再重新登录到plsql下recompile刚才的存储过程A就OK了
处理方法一 :
1.SELECT saddr,sid,serial#,paddr,username,status FROM v$session
WHERE username IS NOT NULL
example:saddr,sid,serial#,paddr,username,status FROM v$session WHERE
username = 'XNJW0419' ;
SADDR SID SERIAL# PADDR USERNAME STATUS
-------- ---------- ---------- --------
------------------------------ --------
542E0E6C 11 314 542B70E8 EYGLE INACTIVE 542E5044 18 662 542B6D38 SYS
ACTIVE
2.ALTER SYSTEM KILL SESSION 'sid, serial#';
example:ALTER SYSTEM KILL SESSION '11,314';(注:在sqlplus中执行 )
结果: 提示标记要删去的会话 无法释放会话,未成功解锁
====================================================================================================
处理方法二 :
a、 找到你要杀掉的那个SESSION, 并记下paddr
SELECT sid, username, paddr, status FROM v$session WHERE username =
'用户名' ;
example:SELECT sid, username, paddr, status FROM v$session WHERE
username = 'XNJW0419' ;
SID USERNAMEPADDRSTATUS
---------- ------------------------------ -------- --------
10 XNJW04192B5E2E2C KILLED
b、 找到这个SESSION所对应的spid
SELECT * FROM v$process WHERE addr = '上面查寻的paddr';
example:SELECT ADDR,PID,SPID,USERNAME,SERIAL#,TERMINAL FROM
v$process WHERE addr = '2B5E2E2C';
ADDRPID SPIDUSERNAMESERIAL# TERMINAL
-------- ---------- ------------ --------------- ----------
----------------
2B5E2E2C44 1204SYSTEM-99 JWC
c、 杀掉spid所标识的那个进程
D:>orakill sid spid (注:cmd命令窗口中执行 只有oracle服务器端才有orakill命令)
example: D:>orakill oemrep 1204
提示:KILL OF THREAD id 1204 IN INSTANCE oemrep successfully signalled.
结果:成功删除该SESSION,表也解锁