Skip to content

feat(metadata): add resilient match queue diagnostics - #463

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/match-queue-diagnostics
Jul 24, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/match-queue-diagnostics

Conversation

@Rhainland

@Rhainland Rhainland commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Part of #196.

Scope

Queue lifecycle, persistence, migrations, API diagnostics, and the extracted admin queue UI for metadata matching. This PR is stacked on #461 and must merge after it.

What changed

  • Bounds claims by worker availability and carries lease ownership through completion/failure.
  • Releases unfinished claims after cancellation or batch errors.
  • Fences Retry Now and input-change wakeups so active workers cannot delete or overwrite requested reruns.
  • Persists durable rerun intent across lease expiry, release, transient failure, and reclaim.
  • Adds bounded failure taxonomy/diagnostics, deterministic retry scheduling, parking, input fingerprints, and bulk queue status.
  • Builds the supporting media_files index concurrently in a retry-safe Goose NO TRANSACTION migration.
  • Adds paginated admin queue details and retry controls.

Verification

Passed on head d996c4030dec1bad3aca7358e77cb10ca35bc888:

  • focused Go packages: providerid, naming, catalog, metadata, scanner, API handlers, and migrations
  • PostgreSQL-backed queue lifecycle groups: deterministic parking/retry, transient retry budget, changed-input wake, leased Retry Now fencing, and ineligible-rerun cleanup
  • combined focused Vitest: 10/10
  • production frontend build
  • pnpm --dir web run lint: 0 errors (158 existing warnings)
  • pnpm --dir web run format:check
  • make verify-local-paths and git diff --check
  • complete stacked-diff golangci-lint --new-from-rev eee63772: 0 issues
  • clean final adversarial review (confidence 0.86)

The exact head is deployed to the dev LXC with SDK v0.12.0. Health/readiness are green; both migrations applied; snapshot_language, rerun_requested, and lease_forced_rerun are present; both new indexes are valid/ready; source checksums match; and the live UI bundle contains Match reasons and Retry now. The protected admin queue endpoint is registered and correctly rejects unauthenticated access.

Browser automation was not attached to the authenticated preview, so visual proof is covered by the deployed bundle and passing component tests. Repository-wide make lint still reports 306 pre-existing findings outside this diff.

AI Disclosure

  • Tool(s): Codex CLI, Claude Code
  • Model(s): gpt-5.6-sol, claude-fable-5
  • Involvement: AI-assisted
  • Adversarial review: Rechecked lease ownership, cancellation, retry/wake races, durable rerun intent, claim bounds, migration/index safety, pagination, API bounds, and UI state. The final review was clean; the review helper's empty SQL lease-token sentinel false positive was handled in a disposable identifier-redacted bundle while the exact ship tree was tested independently.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Quick104, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dfa1f2c5-60de-461d-8ee6-3e7990b569e2

📥 Commits

Reviewing files that changed from the base of the PR and between 383973e and d996c40.

📒 Files selected for processing (24)
  • cmd/silo/main.go
  • internal/api/handlers/libraries.go
  • internal/api/handlers/libraries_match_test.go
  • internal/metadata/match_queue_coordinator.go
  • internal/metadata/match_queue_policy.go
  • internal/metadata/match_queue_state_db_test.go
  • internal/metadata/movie_match_queue_repo.go
  • internal/metadata/series_root_match_queue_repo.go
  • internal/metadata/worker.go
  • internal/metadata/worker_test.go
  • internal/models/media_group.go
  • internal/plugins/service.go
  • internal/plugins/service_admin_config.go
  • internal/scanner/file_repo.go
  • migrations/sql/20260721211627_metadata_match_queue_state.sql
  • migrations/sql/20260723214954_media_files_series_match_fingerprint_index.sql
  • migrations/sql/20260724135931_add_metadata_match_queue_rerun_requests.sql
  • web/src/api/types.ts
  • web/src/components/admin/CollapsibleDiagnosticsSection.tsx
  • web/src/components/admin/libraries/MetadataMatcherQueuesSection.test.tsx
  • web/src/components/admin/libraries/MetadataMatcherQueuesSection.tsx
  • web/src/hooks/queries/admin/libraries.ts
  • web/src/pages/AdminLibraries.test.tsx
  • web/src/pages/AdminLibraries.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Rhainland
Rhainland force-pushed the fix/match-queue-diagnostics branch 2 times, most recently from 865a6dc to cc4b1de Compare July 23, 2026 23:11

Copy link
Copy Markdown
Contributor Author

@Quick104 This is the policy split for the queue-lifecycle and admin-diagnostics work you reviewed on #461. The queue-specific change is the single commit cc4b1de6; GitHub temporarily shows the stacked core commit because contributor-fork PRs cannot target another fork branch. That core diff will disappear here when #461 merges.

Your lease-release, Retry/Wake race, concurrent-index, and failure-kind UI findings are all fixed with focused cancellation/race/migration/component coverage. The post-fix adversarial review and CodeRabbit sweep found no remaining queue findings. Could you please review this queue-specific commit as well?

@Quick104
Quick104 force-pushed the fix/match-queue-diagnostics branch from cc4b1de to 9818806 Compare July 24, 2026 15:54
@Quick104
Quick104 force-pushed the fix/match-queue-diagnostics branch from 9818806 to d996c40 Compare July 24, 2026 16:15
@Quick104
Quick104 marked this pull request as ready for review July 24, 2026 16:18

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the final queue-only diff on merged main. Lease fencing, durable reruns, claim bounds, migration/index safety, API pagination, UI state, focused tests, database-backed tests, changed-diff lint, adversarial review, and exact-SHA dev deployment are all clean.

@Quick104
Quick104 merged commit 22fec4e into Silo-Server:main Jul 24, 2026
2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d996c4030d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

rerun_requested = rerun_requested OR lease_forced_rerun,
lease_forced_rerun = false,
attempt_count = GREATEST(attempt_count - 1, 0), updated_at = NOW()
WHERE lease_token = $1 AND state = 'pending'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add an index for lease-token releases

On large pending queues, this new release path has to find rows by a unique lease_token, but the added migrations only index claim ordering and do not support this predicate; processQueuedMovieFiles calls ReleaseLease once per claimed batch even when all rows were already completed, so a big backlog can force repeated scans just to update zero unfinished rows. Please add a partial lease-token index for non-empty leases, and mirror it for the series queue's identical release path, before relying on this under load.

AGENTS.md reference: AGENTS.md:L13-L15

Useful? React with 👍 / 👎.

// inputs that can change a result without changing the queue key. Arguments
// are internal SQL expressions selected by repository code, never user input.
func matchQueueInputFingerprintSQL(pathExpression, typeExpression, folderIDExpression, languageExpression string) string {
return fmt.Sprintf(`md5(%s || '|' || COALESCE(%s, '') || '|' || COALESCE(%s, '') || '|%d|' || COALESCE((

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include file hashes in queue fingerprints

For a same-path replacement or rescan where only media_files.file_hash changes, this fingerprint stays unchanged because it hashes the path/type/language/provider inputs but not the hash. The worker passes representative.FileHash into MatchHints, and Process seeds it as the oshash provider ID, so providers can make a different match decision while a parked row remains parked instead of resetting on the new scan; include the file hash, and per-file hashes in the series shape, in the fingerprint.

Useful? React with 👍 / 👎.

chain.capability_id || ':' || chain.content_level || ':' ||
chain.enabled::text || ':' || installation.enabled::text || ':' || installation.version || ':' ||
COALESCE((
SELECT string_agg(config.config_key || ':' || config.updated_at::text, ',' ORDER BY config.config_key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wake queues for plugin-owned config writes

Once config.updated_at is part of the match input fingerprint, every runtime-config write needs to fire the lifecycle wake. The admin setter now does, but plugins can still call RuntimeHostServer.SetGlobalConfigEntry, which is wired in cmd/silo/main.go directly to runtimeConfigStore.PutGlobalConfig without OnLifecycleChange; for a metadata provider that refreshes OAuth/bootstrap config this changes the fingerprint while parked rows stay asleep until restart or another lifecycle event. Route that setter through the service hook or explicitly wake queues too.

AGENTS.md reference: AGENTS.md:L39-L45

Useful? React with 👍 / 👎.

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