首页 技术 正文
技术 2022年11月21日
0 收藏 391 点赞 4,389 浏览 3486 个字

  今天突然出了个奇怪的问题,原本正常启动的项目,在什么都没有修改的情况下,启动到一半的时候会卡住几分钟,几分钟后又成功启动了,刚好是卡在Quartz那里,还以为出什么奇奇怪怪的幺蛾子了,一看日志,数据库锁住了~ 记录一下解决方法。

  转载 : http://blog.csdn.net/mchdba/article/details/38313881

  

1,查看数据库的隔离级别:

mysql> select @@tx_isolation;
+—————–+
| @@tx_isolation  |
+—————–+
| REPEATABLE-READ |
+—————–+
1 row in set (0.00 sec)

mysql>

2,去查看先当前库的线程情况:

mysql> show full processlist;

+———-+—————–+——————-+—————–+————-+———+————————-+———————–+

| Id       | User            | Host              | db              | Command     | Time    | State                   | Info                  |

+———-+—————–+——————-+—————–+————-+———+————————-+———————–+

|        1 | event_scheduler | localhost         | NULL            | Daemon      | 9635385 | Waiting on empty queue  | NULL                  |

|  9930577 | business_web    | 192.168.1.21:45503 | business_db     | Sleep       |     153 |                         | NULL                  |

|  9945825 | business_web    | 192.168.1.25:49518 | business_db     | Sleep       |      43 |                         | NULL                  |

|  9946322 | business_web    | 192.168.1.23:44721 | business_db     | Sleep       |     153 |                         | NULL                  |

|  9960167 | business_web    | 192.168.3.28:2409  | business_db     | Sleep       |      93 |                         | NULL                  |

|  9964484 | business_web    | 192.168.1.21:24280 | business_db     | Sleep       |       7 |                         | NULL                  |

|  9972499 | business_web    | 192.168.3.28:35752 | business_db     | Sleep       |      13 |                         | NULL                  |

| 10000117 | business_web    | 192.168.3.28:9149  | business_db     | Sleep       |       6 |                         | NULL                  |

| 10002523 | business_web    | 192.168.3.29:42872 | business_db     | Sleep       |       6 |                         | NULL                  |

| 10007545 | business_web    | 192.168.1.21:51379 | business_db     | Sleep       |     155 |                         | NULL                  |
……

+———-+—————–+——————-+—————–+————-+———+————————-+———————–+

没有看到正在执行的慢SQL记录线程,再去查看innodb的事务表INNODB_TRX,看下里面是否有正在锁定的事务线程,看看ID是否在show full processlist里面的sleep线程中,如果是,就证明这个sleep的线程事务一直没有commit或者rollback而是卡住了,我们需要手动kill掉。

mysql> SELECT * FROM information_schema.INNODB_TRX\G;

*************************** 1. row ***************************

trx_id: 20866

trx_state: LOCK WAIT

trx_started: 2014-07-31 10:42:35

trx_requested_lock_id: 20866:617:3:3

trx_wait_started: 2014-07-30 10:42:35

trx_weight: 2

trx_mysql_thread_id: 9930577

trx_query: delete from dltask where id=1

trx_operation_state: starting index read

trx_tables_in_use: 1

trx_tables_locked: 1

trx_lock_structs: 2

trx_lock_memory_bytes: 376

trx_rows_locked: 1

trx_rows_modified: 0

trx_concurrency_tickets: 0

trx_isolation_level: READ COMMITTED

trx_unique_checks: 1

trx_foreign_key_checks: 1

trx_last_foreign_key_error: NULL

trx_adaptive_hash_latched: 0

trx_adaptive_hash_timeout: 10000

trx_is_read_only: 0

trx_autocommit_non_locking: 0

3,看到有这条9930577的sql,kill掉,执行kill 9930577;

mysql> kill 9930577;

Query OK, 0 rows affected (0.00 sec)

mysql>

然后再去查询INNODB_TRX表,就没有阻塞的事务sleep线程存在了,如下所示:

mysql> SELECT * FROM INNODB_TRX\G;

Empty set (0.00 sec)

ERROR:

No query specified

mysql>

再去执行update语句,就能正常执行了,如下所示:

mysql> update order_info  set province_id=15  ,city_id= 1667  where order_from=10 and order_out_sn=’1407261241xxxx’;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql>

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,997
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,356
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,139
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848