Stop album art from blocking page loads
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m39s
CI / test (push) Successful in 3m38s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m39s
CI / test (push) Successful in 3m38s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 5s
Root cause: gunicorn runs only 2 sync workers, and GET /api/v1/art/album did its MusicBrainz + Cover Art Archive work synchronously inside the request (2-12+ seconds per call, measured). A page with several uncached albums could tie up the entire application - every endpoint, every user - for as long as that took. Separately, even an already-resolved album re-streamed its image bytes live from Cover Art Archive on every single page view, by the original v1 design. The endpoint is now cache-only: it reads the album_art table and, if resolved, a local file, and never touches the network. A cache miss records a "pending" row and returns 404 immediately - the frontend already treats 404 as "show the placeholder," so no frontend changes are needed. A new background worker task (the same claim-with- FOR-UPDATE-SKIP-LOCKED pattern already used by imports and federation deliveries) does the actual resolving and downloads the image bytes to a shared volume, completely decoupled from any request. No migration needed: AlbumArt.status just gains a new "pending" value. Verified against the real docker compose stack (not just the test suite): cold lookups for 5 real albums all returned 404 in well under 0.2s (previously 2-12+s each), the worker resolved all 5 within ~10s in the background, and resolved art then served in single-digit milliseconds from the volume, including after a full container restart (no re-download). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
This commit is contained in:
1 parent
79193fbc8e
commit
83b27d7ba1
11 files changed
+345
-68
No files matched your search
+3
-13
@@ -1531,18 +1531,8 @@
|
||||
"422": {
|
||||
"$ref": "#/components/responses/UNPROCESSABLE_CONTENT"
|
||||
},
|
||||
"502": {
|
||||
"description": "MusicBrainz or Cover Art Archive is unreachable",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "No cover art found for this album",
|
||||
"description": "No cover art available yet",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
@@ -1569,7 +1559,7 @@
|
||||
}
|
||||
},
|
||||
"summary": "An album's cover art",
|
||||
"description": "Resolved via MusicBrainz + Cover Art Archive and cached; bytes are proxied on every\ncall, so cache this response client-side.",
|
||||
"description": "Served from a local cache that a background worker task keeps filled; this endpoint\nnever makes a live MusicBrainz/Cover Art Archive call, so it can't be slowed down by\none. An album seen for the first time returns 404 until the worker resolves it,\ntypically within a few seconds - cache this response client-side and retry later.",
|
||||
"tags": [
|
||||
"Art"
|
||||
],
|
||||
@@ -3453,7 +3443,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Art",
|
||||
"description": "Album art, proxied from MusicBrainz / Cover Art Archive"
|
||||
"description": "Album art, resolved from MusicBrainz / Cover Art Archive by a background worker"
|
||||
},
|
||||
{
|
||||
"name": "Health",
|
||||
|
||||
Reference in new issue
Block a user