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 ...
随机推荐
- iframe详细用法
<iframe>是框架的一种形式,也比较常用到. 例子1.<iframe width=420 height=330 frameborder=0 scrolling=auto src= ...
- 精确到时分秒的jQuery插件例子
demo.html: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&q ...
- mysql中的timestamp类型时间比较:unix_timestamp函数
在mysql中,某字段的类型设置为了timestamp,那么我们现在希望取出指定时间段的记录,该如何做呢? 在php中有time()和strtotime()来进行日期和时间戳的格式化,而在mysql中 ...
- ♫【模式】Curry化
/** * 当发现正在调用同一个函数,并且传递的参数绝大多数都是相同的, * 那么该函数可能是用于Curry化的一个很好的候选参数 */ ;(function() { function add(x, ...
- 495. Kids and Prizes
http://acm.sgu.ru/problem.php?contest=0&problem=495 学习:当一条路走不通,换一种对象考虑,还有考虑对立面. 495. Kids and Pr ...
- C++中new和malloc
1.malloc的工作原理: malloc使用一个数据结构(链表)来维护分配空间链表的构成:分配的空间/上一个空间的数据/下一个空间/空间大小等信息. 对malloc分配的空间不要越界访问,因为 ...
- HDU 4716 A Computer Graphics Problem 2013年四川省赛题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4716 题目大意不用解释了吧,看案例就能明白 #include<cstdio> #inclu ...
- JavaScript高级程序设计19.pdf
注册处理程序 navigator.registerContentHandler("applicat/rss+xml","http://www.somereader.com ...
- nginx简单双机热备:backup参数的使用
nginx简单双机热备:backup参数的使用 nginx简单双机热备:backup参数的使用
- ERROR: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the
hbase shell下list命令出错. [hadoop@djt002 hbase]$ hbase shell 2016-07-20 19:37:12,522 INFO [main] Confi ...