Skip to content

fix(search): recover Meilisearch indexes safely - #21

Merged
shekohex merged 3 commits into
mainfrom
agent/leo/d8df3302
Aug 12, 2026
Merged

fix(search): recover Meilisearch indexes safely#21
shekohex merged 3 commits into
mainfrom
agent/leo/d8df3302

Conversation

@shekohex

@shekohex shekohex commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove invalid series.num uniqueness assumption that broke provider refreshes.
  • Replace destructive pre-sync index flushing with verified atomic Meilisearch rebuilds after successful catalog sync.
  • Add hourly full-catalog fingerprint reconciliation for missing, empty, stale, count-mismatched, or settings-mismatched indexes.
  • Serialize forced post-sync rebuilds, bypass redundant health scans, and isolate per-index failures.
  • Block destructive Scout index commands in production and tolerate temporary Meilisearch startup outages.
  • Align searchable payloads with configured sortable/filterable attributes.

Root Cause

Provider series ordering changed, causing existing records to temporarily share num values during upsert. SQLite rejected refresh with UNIQUE constraint failed: series.num. Search indexes had already been flushed, leaving both indexes empty after database sync aborted.

Recovery

  • Build replacement indexes under unique temporary names.
  • Apply settings and import documents in chunks.
  • Verify replacement document count before atomic swap.
  • Keep live index untouched when build or validation fails.
  • Compare deterministic fingerprints across every database and indexed document.
  • Wait for active reconciliation before forced post-sync rebuilds.
  • Attempt both indexes before surfacing per-index failures.
  • Reconcile hourly and after successful media refresh.
  • Provide php artisan lionz:reconcile-search --force for manual recovery.

Verification

  • 337 passed Unit/Feature tests, 2,866 assertions.
  • Real Meilisearch integration: 2 passed, 8 assertions.
  • Changed PHP files: PHPStan passes.
  • Pint, Prettier, TypeScript, ESLint, Composer validation, frontend build pass.
  • GitHub Actions: 5/5 checks pass.
  • All five review threads addressed and resolved.
  • Full-project PHPStan still reports four pre-existing errors in SyncCategories, MediaCategoryAssignment, and UserCategoryPreference.

Related: ZRO-1

Co-authored-by: multica-agent <github@multica.ai>

@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: 20f12cc83a

ℹ️ 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".

Comment thread app/Actions/ReconcileSearchIndexes.php Outdated
Comment thread database/migrations/2026_08_12_000001_drop_unique_num_index_from_series_table.php Outdated
Co-authored-by: multica-agent <github@multica.ai>

@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: f7317c8cac

ℹ️ 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".

Comment thread app/Actions/ReconcileSearchIndexes.php
Comment thread app/Actions/ReconcileSearchIndexes.php Outdated
Comment thread app/Actions/ReconcileSearchIndexes.php Outdated
Co-authored-by: multica-agent <github@multica.ai>
@shekohex
shekohex merged commit 5515d8b into main Aug 12, 2026
5 checks passed
@shekohex
shekohex deleted the agent/leo/d8df3302 branch August 12, 2026 19:03
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.

1 participant