Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1340336
  • 博文数量: 243
  • 博客积分: 888
  • 博客等级: 准尉
  • 技术积分: 2955
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-05 14:33
个人简介

漫漫长路,其修远兮!

文章分类

全部博文(243)

文章存档

2017年(2)

2016年(22)

2015年(32)

2014年(57)

2013年(107)

2012年(23)

分类: Mysql/postgreSQL

2013-12-13 13:32:53

最近出现了两次死锁的情况

1.查看innodb的情况
show engine innodb status
查看事物相关的部分

2.show full processlist 
想要更好的筛选信息可以查询系统表PROCESSLIST,主要关注
select ID,COMMAND,TIME,STATE,INFO from PROCESSLIST;

找出一些进程的所有ID,拼凑成一个字符串
select DB,GROUP_CONCAT(ID) from PROCESSLIST  where (需要的查询条件)\G
然后kill 掉相关的线程

点击(此处)折叠或打开

  1. select Id,user,command,time,state,info from information_schema.processlist where user='3jianhao' and db='OSS' order by time desc limit 100;


点击(此处)折叠或打开

  1. select concat('KILL ',id,';') from information_schema.processlist where user='3jianhao' and db='OSS'  ----查看
  2. select concat('KILL ',id,';') from information_schema.processlist where user='3jianhao' and db='OSS' into outfile '/tmp/killall.txt';

  3. source /tmp/killall.txt;



3.查看锁的相关信息
主要关注三个表
innodb_lock_waits 
innodb_trx 
innodb_locks

SELECT r.trx_id waiting_trx_id,  
       r.trx_mysql_thread_id waiting_thread,
       r.trx_query waiting_query,
       b.trx_id blocking_trx_id, 
       b.trx_mysql_thread_id blocking_thread,
       b.trx_query blocking_query
FROM         information_schema.innodb_lock_waits w
INNER JOIN information_schema.innodb_trx b  ON  b.trx_id = w.blocking_trx_id
INNER JOIN information_schema.innodb_trx r  ON  r.trx_id = w.requesting_trx_id;
阅读(1080) | 评论(0) | 转发(0) |
0

上一篇:mongodb知识链接

下一篇:MongoDB 常用命令

给主人留下些什么吧!~~