Home > Database > Mysql Tutorial > [MySQL]生产环境MySQL数据库事务一直在RUNNING_MySQL

[MySQL]生产环境MySQL数据库事务一直在RUNNING_MySQL

WBOY
Release: 2016-06-01 13:02:27
Original
1198 people have browsed it

前言:

运营人员反映,有一单子提交卡住了,页面一直没有返回。

1,刚开始怀疑是应用服务器或者db压力过高hang住了,马上去check应用服务器以及db的负载,看起来都OK,蛮低的,应该不是DB性能问题。

2,最后去看下是否是表锁住了,查看到有2个事务一直RUNNING,没有结束。,

mysql> select * from INNODB_TRX\G;

3,通过trx_mysql_thread_id: 1662332的去查询information_schema.processlist找到执行事务的客户端请求的SQL线程

4,通过SQL线程,找到应用程序的IP地址以及端口10.2xx.3.xx:23452

5,找到工程之后,再去查看tomcat的应用报错信息,如下:

--- Check the select ID, SHOP_NAME, SHOP_CLASSIFICATION_ID, LEGAL_PERSON, CORPORATION, SHOP_TEL, ADDRESS, ZIP_CODE, LEGAL_PERSON_MOBILE, STAT, AUTHENTICATE, CREDIT, LEVEL, SCORE, LICENSE_PATH, BUSSINESS_RANGE, MALL_ID, FLOOR, BIS_COMPANY, STORE_NO, MANAGER_NAME, MANAGER_TEL, BRIEF, LOGO, FAVOUR_NUM, HAS_WAREHOUSE, DESCRIPTION_FIT, SERVICE, SPEED, BACKGROUND, BIS_CONT_ID,BIS_SHOP_ID, CREATED_DATE, UPDATED_DATE,ENGLISH_PREF from SHOP where SHOP_NAME = ? .

6,现在很明显了,应该是事务未提交,配合开发去check所有的java代码,发现有2处地方,在Exception e里面忘记写rollback了。
} catch (SQLException e) {
}

总结:开发人员,写数据库事务的时候,记得在异常处理Exception的时候,别忘记了rollback。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template