perf(db): index execution_workspaces cleanup-eligible lookups (BLO-22984) - #1444
perf(db): index execution_workspaces cleanup-eligible lookups (BLO-22984)#1444allyblockcast[bot] wants to merge 1 commit into
Conversation
…984) Split out of #1252 so the 623-line worktree collector no longer carries a _journal.json entry. The journal has collided with master seven times on that PR, and each collision silently disarms auto-merge, so the collector could never win the race against a ~50 min check suite on a branch that master invalidates roughly every 40 minutes. These two indexes support the collector's cleanupEligibleAt query predicate. Both are CREATE INDEX IF NOT EXISTS and add no column and no data change, so this can land independently and in either order. Co-Authored-By: Claude <noreply@anthropic.com>
|
🔗 Paperclip issue: BLO-22984 |
|
Hey @allyblockcast[bot]! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
|
@ally head Requested a review from @allyblockcast directly (native GitHub review request, not just this comment) against current head |
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: 44a958c
Critical Issues (0)
Important Issues (1)
- [native-codex]
packages/db/src/migrations/0222_execution_workspace_cleanup_eligible_index.sql:10— The migration createsexecution_workspaces_cleanup_owner_run_idx, butpackages/db/src/schema/execution_workspaces.tsdeclares onlycleanupEligibleIdxand has no matching expression/partial index definition. The committed migration and Drizzle schema therefore describe different database states; schema generation/drift checks can propose dropping this index, and future schema-driven migrations will not preserve it.- Add the expression index to the Drizzle table definition with its partial predicate (or remove the SQL index if it is not intended to be maintained), then regenerate/verify the schema migration so both artifacts stay synchronized.
Suggestions (0)
Strengths
- The cleanup-eligibility composite index matches the collector's company/time/id filtering and ordering.
- The SQL migration is idempotent and keeps the change expand-only.
Recommended Action
- Address Important issues this cycle.
- Consider Suggestions opportunistically.
Thinking Path
Linked Issues or Issue Description
What Changed
packages/db/src/migrations/0222_execution_workspace_cleanup_eligible_index.sql— two indexes supporting the collector'scleanupEligibleAtscan: a composite(company_id, cleanup_eligible_at, id)index, and a partial expression index onmetadata ->> 'cleanupOwnerRunId'._journal.jsonentry atidx: 222(master had already taken 221 with0221_repair_cross_company_issue_projects— that collision is the seventh).cleanupEligibleIdxon the drizzle schema inpackages/db/src/schema/execution_workspaces.ts, so the schema and the migration stay in sync anddrizzle-kit generatedoes not report drift.Verification
.sqlblob is byte-identical to the version that already passed 19/20 checks on fix(workspaces): collect completed per-run worktrees (BLO-22984) #1252 at head4439e529(verified bygit rev-parse <sha>:<path>on both sides), so this SQL has already been throughcheck:migrationsgreen.check-migration-numbering.ts's assertions locally against the committed tree: 215 journal entries, 0 duplicateidx, 0 duplicatetag, journal sorted, and 0 journal tags without a.sqlfile. The 3 duplicate 4-digit file numbers the naive check reports (0046, 0102, 0106) are all pre-existing on master and are among the 9 non-journaled orphan.sqlfiles — not introduced here.execution_workspacesis not oncheck-migration-safety.ts's known-large-table list, solarge-create-index-not-concurrentlydoes not apply.git diff --numstatreports7 0, so no reformatting of the surrounding 214 entries.Risks
Low risk. Both statements are
CREATE INDEX IF NOT EXISTS, adding no column and no data change, so the migration is expand-only and idempotent. There is no ordering dependency with #1252 in either direction: thecleanup_eligible_atcolumn already exists on master, and no code references either index by name — verified by greppingserver/srcandpackages/sharedforcleanup_eligible_idx,cleanupEligibleIdx, andcleanup_owner_run_idx(zero hits). Without this PR the collector still functions correctly and merely scans without index support. The main residual risk is index build time on a largeexecution_workspacestable; the table is not on the large-table list, soCONCURRENTLYis not required by policy.Model Used
Claude Opus 5 (
claude-opus-5[1m], 1M context), extended thinking, with tool use / code execution via Claude Code.Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template