Repository navigation
feat(admin): run full library metadata refreshes from the web - #1337
Conversation
The library refresh button always queued a quick refresh, which skips healthy matched items, so provider-side fixes never reached existing libraries without API calls. The button now opens a dialog offering the quick refresh or a full refresh of every item. A new manual task, Refresh All Library Metadata, runs a full refresh of each enabled library. It runs the library refresh executor inline because admin jobs need a requesting account. A cluster advisory lock allows one task run across servers, and the executor now holds a per-library lock so a refresh job and the task never refresh the same library at once. The typed v2 request helper learns to send JSON bodies the contract marks optional, which the refresh mode needs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (16)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe changes add per-library refresh locking and a manual task for refreshing enabled libraries. The admin interface now offers quick and full refresh choices, and the API client sends the selected mode. ChangesLibrary metadata refresh
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TaskManager
participant RefreshAllLibraryMetadataTask
participant PostgreSQLAdvisoryLock
participant ScanFolderRepository
participant ActiveLibraryRefreshFinder
participant LibraryRefreshRunner
TaskManager->>RefreshAllLibraryMetadataTask: Execute task
RefreshAllLibraryMetadataTask->>PostgreSQLAdvisoryLock: Acquire cluster lock
RefreshAllLibraryMetadataTask->>ScanFolderRepository: List enabled libraries
loop Each enabled library
RefreshAllLibraryMetadataTask->>ActiveLibraryRefreshFinder: Check for active refresh
RefreshAllLibraryMetadataTask->>LibraryRefreshRunner: Execute full refresh
end
Merge Risk: ⚪ Minimal · up to Administrators can now choose between a quick and a full metadata refresh for a library, and can run a manual task that fully refreshes every enabled library. Advisory locks keep refreshes of the same library from overlapping and allow only one full run across servers. No concrete defect remains in the reviewed changes, so the change appears ready to merge. The task has not yet been run on a deployed server. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 14 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
A library refresh job recovered after its worker stopped heartbeating failed straight away on the per-library advisory lock, because the earlier attempt can still hold it: its worker needs up to a heartbeat interval to notice the new claim, and a server that disappears without closing its connection keeps the lock until PostgreSQL drops the session. Recovery used to rerun the refresh to completion. A job on its second or later claim now retries the lock every five seconds, reporting that it is waiting, until the holder lets go, the job is cancelled, or the six-hour job limit runs out. First claims and the full refresh task still fail fast on a held lock. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Problem
Related issue: N/A — requested by a maintainer; follows Silo-Server/silo-plugin-metadata-tvdb#19
Validation tasks: none
Admins have no way to re-fetch metadata for every item in a library from the web UI. The library refresh button in Admin → Libraries always queues a
quickrefresh. That refreshes only matched items that need it, such as ones never refreshed, missing an overview or artwork, with a failed refresh, or with incomplete episodes. A healthy matched item is skipped. So when a provider fixes its data, existing libraries keep the old metadata until each item is refreshed by hand. TVDB season posters picked in the wrong language (fixed in silo-plugin-metadata-tvdb#19) are the current example.POST /api/v2/libraries/{id}/refresh-metadataalready acceptsmode: "full", but only API callers can use it. The scheduledrefresh_metadatatask only works through the refresh-debt queue, so it never reaches healthy items either.Approach
quickrefresh. "Refresh All Metadata" isfull, and it warns that large libraries can take hours. The dialog follows the existing per-item Refresh Metadata dialog.refresh_all_library_metadata) on the Scheduled Tasks page runs afullrefresh of each enabled library in turn, with the same six-hour limit per library as a refresh job. It skips a library that already has a refresh queued or running.admin_jobs.created_by_user_idis required and referencesusers, and a task run has no acting user. Making it nullable would change job ownership and visibility rules across the admin jobs surface, which is out of scope here. The trade-off is that the task keeps no retained job record, doesn't resume after a process failure, and cancels as a whole.docs/admin-tasks-api.mdrecords this.pglock) allows one task run across all servers. A run that finds it held fails instead of recording a refresh that never happened.LibraryRefreshExecutornow holds a per-library advisory lock, which covers both refresh jobs and the task. A refresh of a library that another refresh already holds stops immediately: the job fails with a clear message and the task skips that library.Validation
go build ./...,go vet ./...,gofmt -l .(clean),make lint-changed(0 issues).make test-go: everything passes exceptTestAdminResourceCapabilitiesAndScope. That test needs Linux cgroup support (internal/apiv2/admin_system.goreportsunsupportedon other platforms), and this change doesn't touch it.pnpm run lint,pnpm run format:check,pnpm run build, andmake test-web(614 files, 4795 tests) pass.go test ./internal/adminjob/against a temporary PostgreSQL 18 container with migrations applied, the task tests,go vet, andmake lint-changed(0 issues).go build ./...,make lint-changed, the tests forinternal/adminjob,internal/taskmanager/...,internal/workmetrics, andcmd/..., plusmake test-web. All pass.verify-apiv2-openapi,verify-apiv2-contract,verify-apiv2-fixtures,TestCommittedArtifactMatchesRouter, andverify-local-paths.SILO_TEST_DATABASE_URL). I ran it locally against a temporary PostgreSQL 16 container.modebody.{"mode":"full"}and showed "Full metadata refresh queued"; "Refresh Missing Metadata" sent{"mode":"quick"}. The task hasn't run on a deployed server.Risks
docs/admin-tasks-api.md). Library refresh jobs keep their database-backed cancellation.pglockusers.Checklist
AI Disclosure
Harness: Claude Code (T3 Code)
Tool(s): Claude Code, GitHub CLI, Playwright
Model(s): claude-opus-5-5
Involvement: Fully AI-generated at the maintainer's request; human review pending
Adversarial review: A separate Claude Code review agent (claude-opus-5-5) read the diff against the admin-job runner, the task manager's scheduling,
pglock, and the generated v2 schema. It found no crash or data-loss defects and raised these, all resolved:metadatawork-metrics category. Added.libraries-api.mddidn't describequickandfull. It does now.Task cancel and progress staying on the owning server is a limit of the task manager, noted under Risks.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements