solve_lock-1024-大功告成
create or replace procedure solve_lock_061203(v_msg out varchar2)
as
v_sql varchar2(3000); --定义 v_sql 接受抓取锁的sql语句
kill_sid number;
kill_serial number;
cur_lock sys_refcursor; --定义游标变量,循环执行抓取锁的sql语句
cur_lock02 sys_refcursor;
type tp_lock is record( --定义 record类型的 变量
v_sid number,
v_type varchar2(10),
v_id1 number,
v_id2 number,
v_lmode varchar2(200),
v_request varchar2(200),
v_lock_time number,
v_block number);
records_lock tp_lock;
type tp_lock02 is record(
waiting_sid number,
waiting_sql varchar2(1000),
blocker_event varchar2(1000),
blocking_sid number,
blocking_sql varchar2(1000));
records_lock02 tp_lock02;
v_blocking_sid number;
v_waiting_sid number;
begin
v_msg := '';
v_sql := '';
v_msg := v_msg ||
'------------------查找数据库中是否有锁阻塞、锁等待的情况------------------' ||
chr(10);
-- DBMS_OUTPUT.PUT_LINE('------------------查找数据库中是否有锁阻塞、锁等待的情况------------------');
v_sql := 'select sid,type,id1,id2,
decode(lmode,0, ''none'',1,''null'', 2, ''row share'' ,3, ''row exclusive'' ,4, ''share'' ,5, ''share row exclusive'' ,6 ,''exclusive'' ,''null'') lock_type,
decode(request,0, ''none'',1,''null'', 2, ''row share'' ,3, ''row exclusive'' ,4, ''share'' ,5, ''share row exclusive'' ,6 ,''exclusive'' ,''hull'') lock_request,
ctime,block from v$lock where type in (''TM'',''TX'')';
open cur_lock for v_sql;
loop
fetch cur_lock
into records_lock;
exit when cur_lock%notfound;
if records_lock.v_request <> 'none' then
--抓取发出请求锁的会话
v_msg := v_msg || 'waiting sid: ' || records_lock.v_sid ||
' is request a lock ,lock_mode is ' ||
records_lock.v_request || ' and being locked ' ||
records_lock.v_lock_time || 's' || chr(10);
--dbms_output.put_line('waiting sid: '||records_lock.v_sid||' is request a lock ,lock_mode is '||records_lock.v_request||' and being locked '|| records_lock.v_lock_time||'s');
v_waiting_sid := records_lock.v_sid;
end if;
if records_lock.v_block <> 0 then
--抓取发生锁阻塞的会话
v_msg := v_msg || 'blocking sid: ' || records_lock.v_sid ||
' is make a lock , lock_mode is ' || records_lock.v_lmode ||
chr(10);
/* dbms_output.put_line('blocking sid: ' || records_lock.v_sid ||
' is make a lock , lock_mode is ' ||
records_lock.v_lmode);*/
v_blocking_sid := records_lock.v_sid;
end if;
end loop;
close cur_lock;
v_sql := '';
v_msg := v_msg ||
'------------------查找产生锁的会话、锁等待的会话------------------------' ||
chr(10);
-- dbms_output.put_line('------------------查找产生锁的会话、锁等待的会话------------------------');
v_sql := 'select distinct waiter.sid "waiting_sid",w_sql.sql_text "sql from waiting session",blocker.event "blocker event",blocker.sid "blocking sid",
b_sql.sql_text "sql from blocking session" from v$session waiter, v$session blocker,v$sql w_sql,v$sql b_sql
where waiter.event=''enq: TX - row lock contention'' and waiter.blocking_session=blocker.sid
and w_sql.sql_id=waiter.sql_id
and b_sql.sql_id =nvl(blocker.sql_id,blocker.prev_sql_id)';
open cur_lock02 for v_sql;
loop
fetch cur_lock02
into records_lock02;
exit when cur_lock02%notfound;
if records_lock02.waiting_sid is not null then
v_msg := v_msg || 'waiting sid: ' || records_lock02.waiting_sid ||
' wait_sql is : ' || records_lock02.waiting_sql || chr(10);
/* dbms_output.put_line('waiting sid: ' || records_lock02.waiting_sid ||
' wait_sql is : ' || records_lock02.waiting_sql);*/
end if;
if records_lock02.blocking_sid is not null then
v_msg := v_msg || 'blocking sid: ' || records_lock02.blocking_sid ||
' block_sql is : ' || records_lock02.blocking_sql || chr(10);
/* dbms_output.put_line('blocking sid: ' || records_lock02.blocking_sid ||
' block_sql is : ' ||
records_lock02.blocking_sql);*/
end if;
end loop;
close cur_lock02;
v_msg := v_msg || '------------------解决 锁阻塞、锁等待------------------' ||
chr(10);
-- dbms_output.put_line('------------------解决 锁阻塞、锁等待------------------');
select sid, serial#
into kill_sid, kill_serial
from v$session
where sid = v_blocking_sid;
v_msg := v_msg || 'action: alter system kill session ( ' || kill_sid || ',' ||
kill_serial || ')' || chr(10);
/* dbms_output.put_line('action: alter system kill session ( ' || kill_sid || ',' ||
kill_serial || ')');*/
exception
when no_data_found then
v_msg := v_msg || sqlerrm;
/* dbms_output.put_line(sqlcode || sqlerrm);*/
end solve_lock_061203;
solve_lock-1024-大功告成的更多相关文章
- python3爬取1024图片
这两年python特别火,火到博客园现在也是隔三差五的出现一些python的文章.各种开源软件.各种爬虫算法纷纷开路,作为互联网行业的IT狗自然看的我也是心痒痒,于是趁着这个雾霾横行的周末瞅了两眼,作 ...
- mysql Packet for query is too large (1185 > 1024)异常
注:最近mysql一直提示如下错误 Packet for query is too large (1185 > 1024). You can change this value on the s ...
- 2016年1月25日 《1024伐木累》-小白篇之开发网站,三天!(中篇-2奇怪的IE)-总章节十一
往期回顾: 老王的“先见之明”,解决了困扰耗仔三人的大难题.顺利安装完开发工具,大家投入紧张的工作.航空部领导的突然闯入,IE不兼容,页面错乱,摆在三人面前的形势依然严峻.第一次见这阵仗的耗仔,又会 ...
- BZOJ 1024: [SCOI2009]生日快乐
Description 将一个 \(x\times y\) 的矩形分成 \(n\) 块,让最长边:最短边 最小. Sol 搜索. \(n\) 只有 \(10\) 写一个类似于记搜的东西就好了. Cod ...
- HDU 1024 max sum plus
A - Max Sum Plus Plus Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- RCA:未注意Curl-library Post 1024以上字节时的HTTP/1.1特性导致 HessianPHP 传输数据失败
先列出 HessianPHP 的错误提示: CURL transport error: transfer closed with outstanding read data remaining 基础知 ...
- 使用TarOutputStream出现 request to write '1024' bytes exceeds size in header错误的解决方法
因为测试流程中,所测客户端会根据服务器A返回的response决定发送给服务器B的请求里各参数的值,所以现在需要模拟服务器的响应.而这个项目服务器A的响应式返回一个流,一个GZIP压缩格式流,压缩的是 ...
- nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1044 > 1024
HTTP Status 500 - type Exception report message description The server encountered an internal error ...
- ecshop 加广告出现广告位的宽度值必须在1到1024之间
打开 admin/ad_position.php这个文件,搜索1024,这里你会搜到两个地方 在236行左右 if ($ad_width > 1024 || $ad_width < 1) ...
- mysql root强密码的必要性max_allowed_packet被改成1024引起的风险
前两天运维反馈说,有些机器的max_allowed_packet隔两天就会被改成1024,导致客户端调用时出错,网上有说内存不够的,也有人工修改的. 运维小姑娘一口咬定肯定没有改过的,而且my.cnf ...
随机推荐
- 【HDOJ】2389 Rain on your Parade
读题显然是二分图匹配,看成guest与umbrella的匹配.匈牙利果断TLE了,其实时间卡的相当紧.HK过的,750ms. /* 2389 */ #include <iostream> ...
- Robotium solo.goBack();不起作用,解决方案
今天碰到用solo.goBack();点击手机的返回按键五次有四次起总用.查了半天后发现以下一种替代方法: solo.sendKey(KeyEvent.KEYCODE_BACK); robotium下 ...
- css3倒影
使用CSS3制作倒影 img { -webkit-box-reflect: below 0px -webkit-gradient(linear, left top, left bottom, from ...
- HDU -- 4496
D-City Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Subm ...
- HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...
- STL之map、multimap
map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. map中key值是唯一的.集合中的元素按一定的顺序排列.元素的插入过程是按照排序规则 ...
- nyoj 95 众数问题【水】
众数问题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 所谓众数,就是对于给定的含有N个元素的多重集合,每个元素在S中出现次数最多的成为该元素的重数, 多重集合S重 ...
- list,set,map,数组间的相互转换
1.list转set Set set = new HashSet( new ArrayList()); 2.set转list List list = new ArrayList( new ...
- [转]C++ map容器用法
C++ map的基本操作和使用 原文地址:http://blog.sina.com.cn/s/blog_61533c9b0100fa7w.html Map是c++的一个标准容器,她提供了很好一对一的关 ...
- js冲突怎么解决
a.最容易出现的就是js的命名冲突①.变量名冲突变量有全局变量和局部变量当全局变量变量和局部变量名称一致时,就会js冲突,由于变量传递数值或地址不同就会产生JavaScript错误,甚至死循环.②.方 ...