python - 超过锁定等待超时;尝试重新启动事务 MYSQL Python

标签 python mysql

我有进行 SQL 更新的 Flask 应用程序:

 query = 'update tbl set x="bla" where filename=%s';
 cursor.execute(query, fileName)

此代码适用于多个文件。 突然我在更新时开始遇到这个错误(错误在每次更新调用中再次出现)。

InternalError: (1205, u'Lock wait timeout exceeded; try restarting transaction')

我看过类似的帖子 Getting "Lock wait timeout exceeded; try restarting transaction" even though I'm not using a transaction

但这并没有解决我的问题。

这是我的进程列表: enter image description here

试图杀死一些正在休眠的进程,但没有成功。

来自 SHOW ENGINE INNODB STATUS 的信息:

mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 1136, 5 row lock(s)
MySQL thread id 439228, OS thread handle 139653215057664, query id 7055088 10.66.85.134 admin updating
update tbl set vt_status=\"rescan\" where filename=\'3ec7il\'
Trx read view will not see trx with id >= 131151, sees < 131145

最佳答案

尝试/except终于解决了

try:
   conn = getConn()
finally:
   conn.close()

关于python - 超过锁定等待超时;尝试重新启动事务 MYSQL Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50087147/

相关文章:

python - 同时显示多个vtk渲染窗口

python - 将 Bash 变量读入 Python 脚本

mysql - 复杂的 MySQL 排序

用于多语言词典的 MySQL 数据透视表

mysql - mysql数据库如何设置 super 权限

python - 神秘的 "embedded null byte"错误

python - 有什么方法可以通过解析/拆分 URL 列表来创建 pandas 数据框?

python - 找出数组中的差异

php - 查询和站点锁定

mysql 有语句不返回行