Skip to content

fix: queue cover thumbnail refresh after metadata commit#1334

Open
I-Would-Like-To-Report-A-Bug-Please wants to merge 1 commit into
crocodilestick:mainfrom
I-Would-Like-To-Report-A-Bug-Please:hotfix/metadata-cover-thumbnail-after-commit
Open

fix: queue cover thumbnail refresh after metadata commit#1334
I-Would-Like-To-Report-A-Bug-Please wants to merge 1 commit into
crocodilestick:mainfrom
I-Would-Like-To-Report-A-Bug-Please:hotfix/metadata-cover-thumbnail-after-commit

Conversation

@I-Would-Like-To-Report-A-Bug-Please
Copy link
Copy Markdown

Saving metadata with a fetched cover queued thumbnail clear/regeneration immediately after the cover file was downloaded, before the edit request had finished applying metadata and committing the Calibre DB transaction. In the live container, the app wedged after queuing those thumbnail tasks and before logging the edit commit.

Defer thumbnail cache replacement until after the metadata transaction commits, so background thumbnail work cannot race the active edit session. Add per-stage debug timings around the edit-save path so future stalls identify the exact metadata step that stopped progressing.

Saving metadata with a fetched cover queued thumbnail clear/regeneration immediately after the cover file was downloaded, before the edit request had finished applying metadata and committing the Calibre DB transaction. In the live container, the app wedged after queuing those thumbnail tasks and before logging the edit commit.

Defer thumbnail cache replacement until after the metadata transaction commits, so background thumbnail work cannot race the active edit session. Add per-stage debug timings around the edit-save path so future stalls identify the exact metadata step that stopped progressing.
@new-usemame
Copy link
Copy Markdown

Same race condition is fixed in the community-maintained CWA build at new-usemame/Calibre-Web-NextGen via fork PR #135 (parallel patch from @navels in CWA #1346), shipped in v4.0.46. Thumbnail cache replacement runs after calibre_db.session.commit() returns, and the worker receives a snapshot of book.path + last_modified so it never re-touches metadata.db for the single-book refresh case.

Thanks @I-Would-Like-To-Report-A-Bug-Please for the independent diagnosis and the static-pin test — both threads landed on the same defer-until-after-commit fix.

If you've seen the web UI wedge after saving metadata with a fetched cover, the fix is at docker pull ghcr.io/new-usemame/calibre-web-nextgen:latest. Fork tracker: https://github.com/new-usemame/Calibre-Web-NextGen/issues.

@I-Would-Like-To-Report-A-Bug-Please
Copy link
Copy Markdown
Author

Np @new-usemame, if it helps I am runnning my own docker image, with this, and few other PR patches I’ve submitted recently.
All is fine, and stable without any problems, and restored functionality for lubimyczytac. (I had to put in additional PR patch for the deadlock tha somebody else has submitted and IIRC cwa-nextgen did the same thing). It would be awesome if others could be merged in :) (https://github.com/crocodilestick/Calibre-Web-Automated/pulls/I-Would-Like-To-Report-A-Bug-Please)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants