mysql - mysql中等待死锁的默认时间
问题描述
我正在使用以下 mysql 模式:
try:
print ('111111')
self.cursor.execute(sql, values)
print ('222222') # print to see how long timeouts are taking...
except Exception as error:
# Most likely a deadlock, retry if NumAttemps <= MaxAttempts
logger.exception(error)
...
在另一个 mysql 客户端中,为了模拟死锁,我正在做这样的事情:
begin;
select * from records where id='10.5240-D5CF-3' for update;
这是可行的,因为它会抓住死锁并且mysql
代码将进入except
块,通常会出现错误:
pymysql.err.InternalError: (1205, 'Lock wait timeout exceeded; try restarting transaction')
有没有办法指定cursor
在引发超时错误之前将等待多长时间/或者如果有锁则在它“放弃”之前等待多长时间?两者都由 处理innodb_lock_wait_timeout
,还是有多个设置?
解决方案
推荐阅读
- c# - How to launch N tasks (or threads) to run the same method that may return useless results?
- python - 在 python 中使用 nsepy 下载数据时如何传递多个执行价格或执行价格范围
- python - 您如何在套接字上使用线程来安全打印
- c# - SHIFT + Scroll 在 ScrollViewer UWP 中水平滚动
- r - ipw 中的错误:如何处理数学函数的非数字参数
- typescript - Nativescript Tabview 自动更新
- angular - 设置Formgroup有效或无效角度7
- javascript - 在 Alexa lambda javascript 代码中,如何获取当前帐户的名称?
- android - 是否依赖于 Flutter SDK 平台
- vim - VIM:设置 term=xterm 更改
到 ,它是可逆的吗?