qd-today / qd

QD [v20240210] —— HTTP请求定时任务自动执行框架 base on HAR Editor and Tornado Server
https://qd-today.github.io/qd/
MIT License
4.2k stars 546 forks source link

[Bug] 使用 mysql 数据库有时会出现 Lock wait timeout exceeded 的报错 #511

Closed NineHolic closed 6 months ago

NineHolic commented 6 months ago

Verify steps

QD Version

20240210

Bug on OS

Linux

Bug on Platform

Docker/Linux 64位

To Reproduce

Describe the Bug

使用 mysql 5.7.30 数据库,2月27日 将 20230718 升级到 20240210,从 3月6日 开始有时会出现 Lock wait timeout exceeded 的报错,tpl 表也只有 53 条数据,尝试给 tpl 表加 id 索引时,也会出现大量报错,即使重启容器,第二天还会有报错,每天的报错数量开始变多

QD config

配置文件使用 mysql 数据库,其它修改地方如下

# 任务运行中单个 While 循环最大运行时间由 900 改为 7200
task_while_loop_timeout = int(os.getenv('TASK_WHILE_LOOP_TIMEOUT', '7200')) 

# 任务运行中单个任务最大请求次数由 1500 改为 50000
task_request_limit = int(os.getenv('TASK_REQUEST_LIMIT', '50000'))  

# HTTP Request 请求超时时间由 30 改为 60 
request_timeout = float(os.getenv('REQUEST_TIMEOUT', '60.0'))   

# HTTP Request 连接超时时间由 30 改为 60
connect_timeout = float(os.getenv('CONNECT_TIMEOUT', '60.0'))

QD log

[E 240308 17:19:39 QD.Worker worker:310] taskid:3 tplid:5 failed! 75.0485s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889507, 5)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:50 tplid:27 failed! 75.0506s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889506, 27)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:25 tplid:11 failed! 75.0877s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889519, 11)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:38 tplid:22 failed! 75.0865s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889517, 22)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:127 tplid:65 failed! 73.2931s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889513, 65)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:68 tplid:42 failed! 75.0913s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889524, 42)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:2 tplid:6 failed! 75.3457s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889522, 6)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:21 tplid:7 failed! 75.0939s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889522, 7)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:93 tplid:5 failed! 75.2374s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889507, 5)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:103 tplid:47 failed! 75.0400s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889523, 47)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:52 tplid:27 failed! 75.0716s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889507, 27)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:94 tplid:11 failed! 75.0350s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889523, 11)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:53 tplid:27 failed! 75.0461s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889509, 27)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:132 tplid:65 failed! 73.5675s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889513, 65)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:131 tplid:65 failed! 73.5712s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889523, 65)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 240308 17:19:39 QD.Worker worker:310] taskid:37 tplid:22 failed! 75.3769s 
    (pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
    [SQL: UPDATE tpl SET success_count=success_count+1, last_success=%s WHERE id=%s]
    [parameters: (1709889518, 22)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)

Expected behavior

无报错

Screenshots

image

a76yyyy commented 6 months ago

请更新至 dev 版本后重试

NineHolic commented 5 months ago

请更新至 dev 版本后重试

更新后已正常