Ingestion concurrency + scale review (phases 1-2); fixes held for db-reliability#339
Merged
Merged
Conversation
Read-only live profiling (explain_retrieval_rpc + direct EXPLAIN ANALYZE via MCP; profile:retrieval's underlying RPC — no local Supabase credentials). Headline findings: table-facts text RPC already at 6.75s (unindexable trigram OR-disjunct, ~linear growth); index-units hybrid has no vector arm (and no HNSW index); ef_search=40 silently caps every vector arm below its LIMIT (measured 40 vs 72); ~5GB of HNSW on a 256MB-buffer instance; 10-14 RPC fan-out per cold request. Ranked mitigation list included; all changes held for eval-gated follow-up work. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Full state model of documents x ingestion_jobs x indexing_v3_agent_jobs x index generations: legal composite states, writer x transition matrix, and crash-window analysis for all four writers (worker, edge agent, API routes, ops scripts). Violations found by 7 scoped race-hunter agents (one per writer x transition group), consolidated into 24 claims and re-derived by an independent adversarial verifier: 24/24 confirmed (5 narrowed, 0 refuted). Seven are deterministic - no concurrency required - including: aborted DELETEs poison the storage-cleanup ledger so the janitor destroys live documents' storage (R11); retrying a failed job of an indexed doc destroys its live committed index (R15); every successful reindex permanently strands the prior image generation (R12); recovery supersede silently cancels queued reindexes (R22). Root concurrency enabler: no lease heartbeat (R1), making every >45-min job multi-master. Ranked phase-3 fix backlog included; fixes HELD until the db-reliability branch merges. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
BigSimmo
marked this pull request as ready for review
July 6, 2026 18:19
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
BigSimmo
enabled auto-merge
July 6, 2026 18:19
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot stopped work on behalf of
BigSimmo due to an error
July 6, 2026 18:35
Copilot stopped work on behalf of
BigSimmo due to an error
July 6, 2026 18:35
Copilot stopped work on behalf of
BigSimmo due to an error
July 6, 2026 18:35
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phases 1-2 of the ingestion-concurrency/scale review. Docs only — no behavior changes yet. Phase-3 fixes are deliberately held until the db-reliability branch merges; fix commits will be added to this PR afterwards.
Phase 1 —
docs/ingestion-state-machine.mdFull state model of
documents×ingestion_jobs×indexing_v3_agent_jobs× index generations: legal composite states, writer × transition matrix (worker / edge agent / API routes / ops scripts), crash-window analysis, and a verified violations registry.Method: 7 scoped race-hunter agents (one per writer × transition group), 24 consolidated claims, each re-derived by an independent adversarial verifier (exact reaching schedule or killing guard required). 24/24 confirmed, 5 narrowed, 0 refuted. Two facts checked directly against the live catalog.
Highest-severity confirmed findings (7 need no concurrency at all):
failedledger rows with live paths;cleanup:storagethen permanently deletes a live document's PDF + imagesqueued, so the next claim'sreset_document_indexdestroys the live committed indexlocked_bymode:'enrichment'/ worker inline) are mutually unguarded: completed/"good" docs with zero artifacts, duplicate index units, detached cards;repair_strict_enrichment_gate_batchis invoked by nothingingestion_job_stages.job_idFK and a claim RPC that never seeds agent jobs (live verified unaffected)Phase 2 —
docs/scale-readiness-review.mdRead-only live profiling (
explain_retrieval_rpc+ directEXPLAIN ANALYZE; oneSET LOCALexperiment inside a rolled-back transaction). At 10× (~20k docs):match_document_table_facts_textalready takes 6.75 s (unindexable 5-column trigramsimilarity()OR-disjunct); ~linear growth; called 3× in parallel per requestdocument_index_unitshas no vector index and no vector arm — semantic recall for visual/enrichment evidence is structurally zerohnsw.ef_search=40 silently caps every vector arm below its LIMIT (measured 40 vs 72 rows at ef=200)max_connections60Ranked mitigation list in the doc; retrieval-affecting changes must pass the content_mrr@10 eval gate before defaults move.
Phase 3 (pending)
Fix backlog is ranked in the state-machine doc §8 (janitor guard, retry-route demotion fix, lease heartbeat +
locked_byfences, metadata merge, recovery hardening, storage reconciliation, …). Held until db-reliability merges; each fix will be the smallest safe change, via committed migrations + code, gated onverify:cheap,check:indexing,reindex:health.🤖 Generated with Claude Code