Oracle杀会话回滚时间长处理办法

Oracle杀会话回滚时间长处理办法

获取被KILL会话的SID:

sql 复制代码
set line 200 pages 1000
col event for a30
col program for a35
col username for a10
col exec_time for 9999999999
col sql_id for a15
col machine for a30
col ssid for a13
col state for a20
col status for a10
select inst_id||':'||sid||','||serial# ssid,username,sql_id,sql_exec_id,event,
substr(program,1,25) program,machine,state,last_call_et exec_time,status 
from gv$session 
where wait_class<>'Idle' and username is not null 
order by last_call_et;

...
1:633,52377   APPUSER   13bqm6vvsn5s6	 db file sequential read	 sqlplus@etlhost (TNS V1-V3)	etlhost	   WAITING	243509  KILLED

注意最后一列状态为KILLED。

获取被KILL会话对应的操作系统进程号PID:

sql 复制代码
select spid from v$process 
where addr in (select paddr 
from v$session 
where username='APPUSER' and sid=633);

SPID
------------------------
273322

--或者
select spid from v$process 
where addr in (select creator_addr 
from v$session 
where username='APPUSER' and status='KILLED');

或者:

sql 复制代码
SET LINESIZE 100
COLUMN spid FORMAT A10
COLUMN username FORMAT A10
COLUMN program FORMAT A45
 
SELECT s.inst_id,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program
FROM   gv$session s
       JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE  s.type != 'BACKGROUND' 
and s.username='APPUSER';

   INST_ID	  SID	 SERIAL# SPID	    USERNAME   PROGRAM
---------- ---------- ---------- ---------- ---------- ---------------------------------------------
	 1	  633	   52377 273322     APPUSER    sqlplus@etlhost (TNS V1-V3)
	 1	  722	    1331 104848     APPUSER    sqlplus@etlhost (TNS V1-V3)
	 1	  777	   64051 104254     APPUSER    sqlplus@etlhost (TNS V1-V3)
	 1	  938	   51475 104793     APPUSER    sqlplus@etlhost (TNS V1-V3)
	 1	 1101	   55005 161435     APPUSER    plsqldev.exe
	 1	 1172	   21141 101804     APPUSER    sqlplus@etlhost (TNS V1-V3)
	 1	 2036	   42029 161411     APPUSER    plsqldev.exe

7 rows selected.

操作系统层面杀掉对应连接:

bash 复制代码
[oracle@dbhost ~]$ ps -ef | grep oracle | grep LOCAL | grep 273322
oracle   273322      1 28 Oct15 ?        19:25:50 oracleorcldb (LOCAL=NO)

[oracle@dbhost ~]$ kill -9 273322

References

1 https://blog.51cto.com/u_13631369/6251425

相关推荐
二宝哥28 分钟前
02.springboot项目对接国内模型实现对话聊天
数据库·人工智能·spring boot
秦时明月之君临天下1 小时前
MySQL purge 参数详解:innodb_purge_threads 与 innodb_purge_batch_size
数据库·mysql·1024程序员节
三垣网安1 小时前
某某大学心理健康教育平台弱口令及SQL注入漏洞
数据库·sql
打工仔折腾 AI1 小时前
AI Agent 工程化实战(二):5 分钟跑通 Deep Agent 并逐层拆解底层链路
java·数据库·人工智能·后端·python·langchain·ai agent 实战
Shaoshing1 小时前
MySQL视图
数据库
这个DBA有点耶2 小时前
测试全绿,上线三周数据没入账——那个95%的兼容度报告,漏掉的是边界
数据库·mysql·架构
1024奇点2 小时前
【仓颉语言入门 · 第二篇 第 15 课】
开发语言·数据库·ide·开源
xuefuhe2 小时前
Oracle Process termination requested /usr/lib/systemd/systemd
oracle
疯狂学习GIS3 小时前
将谷歌地球引擎账号升级为Contributor与Partner层级的方法
java·数据库·人工智能
gf13211113 小时前
python_高德地图驾车时长查询
数据库·python·mysql