fix(workspace-search): repair wedged search indexing - #712
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
Migrate the delete queue to add the `attempts` column when it predates the schema, and retry transient Workers AI embedding errors in-process. The delete queue survives version resets, so `CREATE TABLE IF NOT EXISTS` never adds `attempts` to an object whose table was created earlier. flushVectorDeletes is the first statement in processBatch and queries `WHERE attempts < ...`, so an affected object throws "no such column: attempts" on every alarm tick and never indexes anything. Add a pragma-guarded ALTER TABLE. Also wrap ai.run in bounded retry with backoff for retryable AiErrors (3xxx internal and 5xx-class upstream) so a transient hiccup like 3043 no longer burns an index attempt or opens an error-tracking issue. Generated-By: PostHog Code Task-Id: 6c0075cb-ea15-438c-8391-1a37c875860b
|
React Doctor found 1 new issue in 1 file · 1 warning · score 92 / 100 (Great) · 1 fixed · vs 1 warning
Reviewed by React Doctor for commit |
| text: batch, | ||
| truncate_inputs: true, | ||
| }); | ||
| const output = await runEmbeddingWithRetry(ai, batch, options); |
There was a problem hiding this comment.
React Doctor · react-doctor/async-await-in-loop (warning)
This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))
Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time
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.
Problem
kernel_search_vector_deletesis created withCREATE TABLE IF NOT EXISTSoutside the version-reset drop set, because its rows reference vectors still live in Vectorize and must survive resets. A Durable Object whose table was created by an earlier iteration of the schema never gains theattemptscolumn —IF NOT EXISTSis a no-op and the reset never touches it.flushVectorDeletesis the first statement inWorkspaceSearchIndexer.processBatchand queriesWHERE attempts < …, so an affected object throwsSqlError: no such column: attemptson every alarm tick and dies before indexing a single item — forever, with no self-healing path.embedWorkspaceSearchTextscallsai.run("@cf/baai/bge-m3", …)with no retry, so a single transientAiError: 3043burns one of the five index attempts and opens a fresh error-tracking issue.Changes
initializeWorkspaceSearchStorage:PRAGMA table_infocheck, thenALTER TABLE kernel_search_vector_deletes ADD COLUMN attempts INTEGER NOT NULL DEFAULT 0when absent. Chosen over moving the table into the reset drop set — a drop would discard queued deletes and orphan their vectors in Vectorize.ai.run: retryableAiErrors (3xxx internal, 5xx-class upstream) are retried in-process (4 attempts, exponential backoff capped at 2s); permanent client/validation codes fail fast. A transient hiccup no longer consumes an index attempt or pages anyone.Note
Failed items are already visible via the lexical fallback —
searchKeywordincludesvector_status = 'failed'andgetStatusreportspartial— so exhausted items keep surfacing in keyword results rather than vanishing.Tests
workspace-search-embeddings.test.ts: retryable-vs-permanent classification, retry-then-succeed, attempt-budget exhaustion, and fail-fast on permanent errors.Why
Restore a brand-new flagship surface (hybrid workspace search) that is silently, permanently broken for any affected workspace, with no client-visible error and no recovery short of a code fix.
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.