janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
13.05k stars 1.39k forks source link

add MySQL support for app.db and gdrive.db #1734

Closed vagra closed 3 years ago

vagra commented 3 years ago

Is your feature request related to a problem? Please describe. My site using calibre-web have many user, (and many spider), outbound traffics >200G/month. sometimes when I change the admin settings, it always report Database Locked!, and cps service crash.

I think this is because the Sqlite are not suitable for multi-threaded access.

Describe the solution you'd like Add MySQL support, let user select Sqlite or MySQL as app/gdrive database. MySQL suitable for multi-thread and many users.

dr400 commented 3 years ago

is your issue related to #1709 ?

OzzieIsaacs commented 3 years ago

Please provide the complete error message, this could also be a limitation of Calibre itself

vagra commented 3 years ago

calibre-web.log

you see,

1.

[2020-11-29 00:43:25,021] ERROR {cps:1892} Exception on /admin/viewconfig [POST]
...
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked

I edit a config and push submit button, then report error and server down.

this is the first error. then...

2. then a large number of error reports followed:

[2020-11-29 00:43:29,368] ERROR {cps:1892} Exception on /book/2552 [GET]
...
sqlalchemy.exc.InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction.

then the site 502, until I restart the server.

vagra commented 3 years ago

is your issue related to #1709 ?

look like my error is app.db locked, when submit to app.db, the db was locked by other, causing the server to crash, and report many errors:

sqlalchemy.exc.InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction.
vagra commented 3 years ago
Platform    Linux 3.10.0-1160.6.1.el7.x86_64 #1 SMP Tue Nov 17 13:59:11 UTC 2020 x86_64 x86_64
Python  3.7.9 (default, Nov 13 2020, 13:40:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Calibre_Web 0.6.10 Beta - $Format:%H$ - $Format:%cI$
WebServer   Gevent 20.9.0
Flask   1.1.2
Flask_Login 0.5.0
Flask_Principal 0.4.0
Werkzeug    1.0.1
Babel   2.8.1
Jinja2  2.11.2
Requests    2.25.0
SqlAlchemy  1.3.20
pySqlite    2.6.0
SQLite  3.33.0
iso639  0.4.5
pytz    2020.4
Unidecode   已安装
Goodreads   已安装
flask_dance 3.0.0
Image Magick    ImageMagick 6.9.10-68 Q16 x86_64 2020-04-01 https://imagemagick.org
PyPdf   v1.26.0
lxml    v4.5.2.0
Wand    0.6.4
Pillow  v7.1.2
Comic_API   未安装
ebook converter 未安装
unrar   未安装
kepubify    未安装
OzzieIsaacs commented 3 years ago

If this error occurs no further action to the normal user base is possible. I went through the code and I now think I catch this erroreverywhere so it should not occur anymore. Please try the newest commit version

vagra commented 3 years ago

ok, hard work. I will try.