janeczku / calibre-web

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

Error during upload of multiple PDF files #2912

Open Eulenbaer opened 11 months ago

Eulenbaer commented 11 months ago

Describe the bug/problem The Server encountered an error during the upload of multiple PDFs via the web-interface. The location of the PDFs is a SMB share e.g. \SERVER\folder\ebook.pdf

To Reproduce Steps to reproduce the behavior:

  1. Login as User
  2. Select 'Upload' from the top right corner
  3. Select multiple PDF files to be uploaded (located at SMB share)
  4. See error

Logfile [2023-10-15 12:51:52,874] WARN {cps.uploader:88} cannot parse metadata, using default: seek of closed file [2023-10-15 12:51:52,886] ERROR {cps:1449} Exception on /upload [POST] Traceback (most recent call last): File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/cursor.py", line 991, in fetchall rows = dbapi_cursor.fetchall() sqlite3.InterfaceError: Cursor needed to be reset because of commit/rollback and can no longer be fetched from.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request rv = self.handle_user_exception(e) File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request rv = self.dispatch_request() File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(req.view_args) File "/app/calibre-web/cps/usermanagement.py", line 35, in decorated_view return login_required(func)(*args, *kwargs) File "/lsiopy/lib/python3.10/site-packages/flask_login/utils.py", line 290, in decorated_view return current_app.ensure_sync(func)(args, kwargs) File "/app/calibre-web/cps/editbooks.py", line 61, in inner return f(*args, **kwargs) File "/app/calibre-web/cps/editbooks.py", line 272, in upload error = helper.update_dir_structure(book_id, File "/app/calibre-web/cps/helper.py", line 718, in update_dir_structure return update_dir_structure_file(book_id, File "/app/calibre-web/cps/helper.py", line 456, in update_dir_structure_file local_book = calibre_db.get_book(book_id) File "/app/calibre-web/cps/db.py", line 652, in get_book return self.session.query(Books).filter(Books.id == book_id).first() File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 2824, in first return self.limit(1)._iter().first() File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 1498, in first return self._only_one_row( File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 559, in _only_one_row row = onerow(hard_close=True) File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 1386, in _fetchone_impl return self._real_result._fetchone_impl(hard_close=hard_close) File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 1801, in _fetchone_impl row = next(self.iterator, _NO_ROW) File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/orm/loading.py", line 147, in chunks fetch = cursor._raw_all_rows() File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 392, in _raw_all_rows rows = self._fetchall_impl() File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/cursor.py", line 1819, in _fetchall_impl return self.cursor_strategy.fetchall(self, self.cursor) File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/cursor.py", line 995, in fetchall self.handle_exception(result, dbapi_cursor, e) File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/cursor.py", line 955, in handle_exception result.connection._handle_dbapi_exception( File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2134, in _handle_dbapiexception util.raise( File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/lsiopy/lib/python3.10/site-packages/sqlalchemy/engine/cursor.py", line 991, in fetchall rows = dbapi_cursor.fetchall() sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Cursor needed to be reset because of commit/rollback and can no longer be fetched from. (Background on this error at: https://sqlalche.me/e/14/rvf5)

Expected behavior Nothing, a successfull upload I guess.

Screenshots ...

Environment (please complete the following information):

Additional context Docker image: https://docs.linuxserver.io/images/docker-calibre-web

OzzieIsaacs commented 11 months ago

I‘m aware of this. It‘s indeed an ugly bug. For now there is only the workaround to upload book by book, or to restore the database from the metadata backup if this error occurs

Eulenbaer commented 11 months ago

Alright, thanks for the reply. I will avoid uploading multiple PDF at once.

OzzieIsaacs commented 11 months ago

The error occurs also with any other file format