Skip to content

fix(knowledge): retry a projection fill page after an index lock or statement timeout instead of ending the chain - #8137

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/projection-fill-lock-timeout-retry
Sep 22, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/projection-fill-lock-timeout-retry

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • A projection fill page that fails with a lock timeout (the keyword index's background maintenance holds its metapage while the page's update needs it) or a statement timeout is now retried in place after a bounded pause (10 s doubling to 60 s with jitter), up to 12 consecutive failures, instead of propagating; before, the Trigger task's run-level retry restarted from the original cursor, re-walked already-filled rows into a statement timeout, and ended the chain after three attempts, which left the keyword projection unfillable while maintenance ran
  • The progress cursor only advances on a successful page, so a continuation never rescans filled rows; a page still failing when the run's budget is spent is handed to the continuation from the last committed page rather than retried past the budget
  • Any other database error still propagates immediately

Type of Change

  • Bug fix

Testing

  • packages/db: vitest run script-migrations/0021_embedding_search_connector.test.ts — 13 passed. New cases: a 55P03 page and a 57014 page are each retried and the cursor is bound to the last committed page on every retry; the run fails once a page times out more than the limit in a row; a non-timeout error propagates without retry; a page still failing at the budget returns done: false with the last committed cursor. Verified the four new cases go red with the retry removed
  • apps/sim: vitest run lib/knowledge/search/projection-source-acl-backfill.test.ts — 21 passed
  • bun run type-check in packages/db and apps/sim, bun run lint at the root, bun run check:migrations origin/staging (no new migrations)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…tatement timeout instead of ending the chain
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 22, 2026 1:54pm UTC

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@greptile-apps

greptile-apps Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previously reported cancellation and run-budget issues are fixed and their threads are resolved.

Summary

This PR makes projection source/ACL backfill pages retry transient lock and statement timeouts without advancing the committed cursor.

  • Retries transient page failures with bounded exponential backoff and jitter.
  • Distinguishes statement timeouts from explicit PostgreSQL cancellations.
  • Rechecks the run deadline after retry pauses before starting another page.
  • Adds coverage for cursor preservation, retry limits, cancellation handling, and budget exhaustion.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Run projection page] --> B{Page result}
    B -->|Committed| C[Advance cursor and reset timeout count]
    C --> D{More rows and budget remains?}
    D -->|Yes| A
    D -->|No| E[Return progress]
    B -->|Non-timeout error or explicit cancellation| F[Propagate error]
    B -->|Lock or statement timeout| G[Increment consecutive timeout count]
    G --> H{Retry limit or budget exhausted?}
    H -->|Yes| I[Fail or return continuation cursor]
    H -->|No| J[Sleep with bounded backoff and jitter]
    J --> K{Budget remains after sleep?}
    K -->|Yes| A
    K -->|No| I
Loading

Reviews (3) · Last reviewed commit: "fix(knowledge): stop the fill page retry..."

Comment thread packages/db/script-migrations/0021_embedding_search_connector.ts
Comment thread packages/db/script-migrations/0021_embedding_search_connector.ts Outdated
Comment thread packages/db/script-migrations/0021_embedding_search_connector.ts Outdated
Comment thread packages/db/script-migrations/0021_embedding_search_connector.ts

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/db/script-migrations/0021_embedding_search_connector.ts Outdated
Comment thread packages/db/script-migrations/0021_embedding_search_connector.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 06d0f7d into staging Sep 22, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/projection-fill-lock-timeout-retry branch September 22, 2026 13:57

This branch was successfully deployed

1 active deployment
Preview 4c962924 Deployed Sep 22, 2026 by vercel[bot]
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