fix(workspace-files): keep the file-search claim on the ordered pending index instead of a hash join - #8128
Merged
Conversation
…ng index instead of a hash join
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
This branch was previously deployed
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
workspace_fileswith an INNER JOIN; underFOR UPDATE(no parallel plans) the planner mis-estimates the timestamp equi-join and picks a hash join over every file and every pending revision of the workspace before the top-N sort, which exceeded the 10 s statement timeout for a workspace with a large backlog and failed the dispatch task with SQLSTATE 57014Type of Change
Testing
SET LOCAL enable_nestloop = off(at fixture scale it already nests the join, so this reproduces production's choice), and asserts theLockRowssubtree is fed by an index scan ofworkspace_file_search_revision_pending_idxwith no sort over the backlog. Verified it fails against the old INNER JOIN spelling (LockRows -> Sort -> Hash Join) and passes with the LATERALvitest run --mode integration lib/workspace-files/search/dispatcher.integration.tsagainst a local disposable PostgreSQL: 9 passedvitest run lib/workspace-files/search/dispatcher.test.ts lib/workspace-files/search/enqueue-dispatch.test.ts: 11 passedbun run type-checkinapps/sim: cleanbun run lint: cleanbun run check:audits: every content audit passed (includingcheck:api-validation:strict,check:sql-date-binding,check:utils,check:source-text); the only failures were audits that shell out toturbo/biome/tscbinaries missing from the isolated worktree, unrelated to this changeChecklist