InternalError: (pymysql.err.InternalError) (1205, u'Lock wait timeout exceeded; try restarting transaction')
在mysql innodb中使用事务,如果插入或者更新出错,一定要主动显式地执行rollback,否则可能产生不必要的锁而锁住其他的操作
我们在使用数据库的时候,可以使用contextlib,这样异常的时候自动回滚,而且最后都会执行关闭操作
from contextlib import contextmanager engine = create_engine(EREBUS_DB_CONNECT_STRING, echo=True, pool_size=150, max_overflow=50, pool_recycle=300)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine,
expire_on_commit=True)) @contextmanager
def session():
try:
session = db_session()
session.expire_on_commit = False
yield session
except:
session.rollback()
finally:
session.close()
http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001478651770626de401ff1c0d94f379774cabd842222ff000
InternalError: (pymysql.err.InternalError) (1205, u'Lock wait timeout exceeded; try restarting transaction')的更多相关文章
- ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
测试库一条update语句报错:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction mysql> ...
- ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction解决办法
一.问题描述: 同事反馈线上一个表有其中一条数据无法删除,其他都正常,我拿到删数据的sql,尝试执行,报错如下: mysql> delete from facebook_posts where ...
- ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 表被锁的解决办法
转自:https://blog.csdn.net/mchdba/article/details/38313881 前言:朋友咨询我说执行简单的update语句失效,症状如下:mysql> upd ...
- Mysql错误:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
昨晚添加完索引之后, 查询整表的时候抛出Lock wait timeout exceeded; try restarting transaction, 吓死小白的我, 为什么条件查询可以, 整表查不了 ...
- 执行 update操作的时候有报错 ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
mysql> show full processlist; #查看问题的线程!!!! 找到异常进程的ID 然后kill 掉: mysql> kill xxxxxxx; #xxxxxx是ID ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
本文为博主原创: 以下为在程序运行过程中报的错误, org.springframework.dao.CannotAcquireLockException: ### Error updating dat ...
- MySQL应用报错:java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
开发反馈,某业务系统插入一条记录的时候,日志报错,插入失败: ### Error updating database. Cause: java.sql.SQLException: Lock wait ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction 问题解决
有两种设置方法 第一种在mysql的配置文件中加入,然后重启mysql innodb_lock_wait_timeout = 500 第二种直接执行如下命令 set global innodb_loc ...
- MySQL事务锁等待超时 Lock wait timeout exceeded; try restarting transaction
工作中处理定时任务分发消息时出现的问题,在查找并解决问题的时候,将相关的问题博客收集整理,在此记录下,以便之后再遇到相同的问题,方便查阅. 问题场景 问题出现的场景: 在消息队列处理消息时,同一事务内 ...
随机推荐
- LVS负载均衡DR模式
什么是集群? 一组相互独立的计算机,利用高速通信网络组成的一个计算机系统,对于客户机来说像是一个单一服务器,实际上是一组服务器.简而言之,一堆机器协同工作就是集群.集群的基本特点:高性能.高并发.高吞 ...
- [ Python ] 基本数据类型及属性(上篇)
1. 基本数据类型 (1) 数字 - int (2) 字符串 - str (3) 布尔值 - bool 2. int 类型中重要的方法 (1) int 将字符串转 ...
- HIbernate学习笔记2 之 主键生成方式
一.hibernate主键生成方式: 1.常用方式:mysql:自增长生成主键(identity) <generator class="identity"> </ ...
- linux命令(11):df命令
1.查看磁盘空间和当前的磁盘数:df –lh或者df –i 2.显示指定类型磁盘:df -t ext4 3.列出各文件系统的i节点使用情况:df -ia 4.列出文件系统的类型:df -T
- Internet Explorer 浏览器在同一时刻只能从同一域名下载两个文件。
Internet Explorer 浏览器在同一时刻只能从同一域名下载两个文件.至于原因请见 MSDN Blogs:<Internet Explorer and Connection Limit ...
- AC日记——小B的询问 洛谷 P2709
小B的询问 思路: 水题: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 50005 #define ll ...
- [水煮 ASP.NET Web API2 方法论](1-3)如何接收 HTML 表单请求
问题 我们想创建一个能够处理 HTML表单的 ASP.NET Web API 应用程序(使用 application/x-www-form-urlencoded 方式提交数据). 解决方案 我们可以创 ...
- .NET ORM SqlQuery
查询 1.SqlQuery 用于执行原生SQL和存储过程 //转成list List<Student> list1 = db.SqlQuery<Student>("s ...
- react native redux saga增加日志功能
redux-logger地址:https://github.com/evgenyrodionov/redux-logger 目前Reac native项目中已经使用redux功能,异步中间件使用red ...
- HDU 1016.Prime Ring Problem-素数环,相邻两数和为素数-DFS
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...