qd-today / qd

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

[Bug] 使用 sqlite3 数据库偶尔会出现 database is locked 的报错 #459

Closed NineHolic closed 1 year ago

NineHolic commented 1 year ago

Verify steps

QD Version

20230718

Bug on OS

Linux

Bug on Platform

Docker/Linux 64位

To Reproduce

Describe the Bug

20230718版本偶尔会出现 database is locked 的报错,使用了默认配置的sqlite3数据库

QD config

config.py为默认配置

QD log

[E 230813 17:58:26 QD.Worker worker:262] taskid:116 tplid:60 failed! 11.3000s
    (sqlite3.OperationalError) database is locked
    [SQL: SELECT user.userkey
    FROM user
    WHERE user.id = ?]
    [parameters: (1,)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)
[E 230813 18:36:26 QD.Worker worker:330] Schedule Producer get tasks failed! (sqlite3.OperationalError) database is locked
    [SQL: SELECT task.id, task.tplid, task.userid, task.disabled, task.retry_count, task.success_count, task.failed_count, task.last_failed_count, task.ctime, task.mtime, task.ontimeflg, task.ontime, task._groups, task.pushsw, task.newontime, task.init_env, task.env, task.session, task.retry_interval, task.last_success, task.last_failed, task.next, task.note
    FROM task
    WHERE task.next <= ?]
    [parameters: (1691922981.5249023,)]
    (Background on this error at: https://sqlalche.me/e/14/e3q8)

Expected behavior

Screenshots

No response

a76yyyy commented 1 year ago

框架目前在数据库层面的优化还不是很好

考虑到 Sqlite3 不支持高度的写并发, 如果您的框架中存在多用户或较多任务同时或者连续进行的情况, 并且您对数据库有一定的了解或使用经验的话, 推荐您切换到 MySQL 来获得更好地使用体验.

NineHolic commented 1 year ago

好的,已迁移至 MySQL