Title: fix(workspace-files): keep the file-search claim on the ordered pending index instead of a hash join by waleedlatif1 · Pull Request #8128 · simstudioai/sim · GitHub
Open Graph Title: fix(workspace-files): keep the file-search claim on the ordered pending index instead of a hash join by waleedlatif1 · Pull Request #8128 · simstudioai/sim
X Title: fix(workspace-files): keep the file-search claim on the ordered pending index instead of a hash join by waleedlatif1 · Pull Request #8128 · simstudioai/sim
Description: Summary The file-search dispatcher's claim query joined workspace_files with an INNER JOIN; under FOR 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 57014 The join is now a correlated LATERAL lookup with LIMIT 1, which cannot be flattened into a hash join, so the claim walks the ordered pending index and stops after the batch size: measured 4.6 s → 0.7 ms on the same workspace, same predicates and lock target Type of Change Bug fix Testing Added an integration test that captures the exact claim statement the dispatcher runs, pins the planner with SET LOCAL enable_nestloop = off (at fixture scale it already nests the join, so this reproduces production's choice), and asserts the LockRows subtree is fed by an index scan of workspace_file_search_revision_pending_idx with no sort over the backlog. Verified it fails against the old INNER JOIN spelling (LockRows -> Sort -> Hash Join) and passes with the LATERAL vitest run --mode integration lib/workspace-files/search/dispatcher.integration.ts against a local disposable PostgreSQL: 9 passed vitest run lib/workspace-files/search/dispatcher.test.ts lib/workspace-files/search/enqueue-dispatch.test.ts: 11 passed bun run type-check in apps/sim: clean bun run lint: clean bun run check:audits: every content audit passed (including check:api-validation:strict, check:sql-date-binding, check:utils, check:source-text); the only failures were audits that shell out to turbo/biome/tsc binaries missing from the isolated worktree, unrelated to this change 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)
Open Graph Description: Summary The file-search dispatcher's claim query joined workspace_files with an INNER JOIN; under FOR UPDATE (no parallel plans) the planner mis-estimates the timestamp equi-join and picks a h...
X Description: Summary The file-search dispatcher's claim query joined workspace_files with an INNER JOIN; under FOR UPDATE (no parallel plans) the planner mis-estimates the timestamp equi-join and picks...
Opengraph URL: https://github.com/simstudioai/sim/pull/8128
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f0cb15e2-88ab-3e41-1772-5a3e69790a8b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 812A:243FA5:1581999:1D5B57D:6AFB79E9 |
| html-safe-nonce | d372f409e9f87002028049d4bc292b11c1cb9f8ab43b7f67d8dd148c45afe70e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTJBOjI0M0ZBNToxNTgxOTk5OjFENUI1N0Q6NkFGQjc5RTkiLCJ2aXNpdG9yX2lkIjoiNzg5NjkyNTEyMzYxNTg4MTcwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 53df72fd0db586159a65714d957b974224b78da6a93e7fe18bf0f7ef626cd9ee |
| hovercard-subject-tag | pull_request:4598836825 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/8128/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary The file-search dispatcher's claim query joined workspace_files with an INNER JOIN; under FOR UPDATE (no parallel plans) the planner mis-estimates the timestamp equi-join and picks a h... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ef32892d4269fb87b55e81cc4ba8d86e0f16aa28446ffbf46cba8be5179ab188 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bc3703b4dcbe820d1284ef63c88b001c850be25e |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width