Skip to content

fix(db): optimize Project backfill and repair archived workflows - #8962

Merged
mzxchandra merged 3 commits into
stagingfrom
codex/project-backfill-bench
Oct 13, 2026
Merged

mzxchandra merged 3 commits into
stagingfrom
codex/project-backfill-bench

Conversation

@mzxchandra

@mzxchandra mzxchandra commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep healthy Project backfill batches at 200 new-Project singletons or 50 existing-Project singletons; process fork families atomically. Remove elapsed-time batch shrinking and the pause after successful batches.

  • Bulk-load existing Project evidence with indexed membership lookups and combine timeout/validation queries to reduce database round trips.

  • Remove the outer 20-minute and 10,000-batch scheduling caps. Preserve transaction timeouts, bounded contention retries, authority/constraint guards, and resumable completion receipts for the existing migration.

  • Automatically archive workflows left active inside archived workspaces, disabling their dependent records in a bounded transaction. Preserve existing archive timestamps and the provider-cleanup guard.

Type of Change

  • Bug fix

Testing

  • 72 focused PostgreSQL integration tests, including partial-progress retry, bulk evidence for distinct/shared Projects, automatic archive repair, rollback, timestamp preservation, provider-cleanup refusal, and temporary/persistent advisory-lock contention.
  • Synthetic database-latency benchmarks verify preserved identities, replay, final constraints, and zero invariant violations.
  • Targeted Biome and git diff checks. Full repository checks run in hosted CI.

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)

@vercel

vercel Bot commented Oct 13, 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 Oct 13, 2026 5:52am UTC

Request Review

@mzxchandra mzxchandra changed the title fix(db): reduce Project backfill round trips and scheduling limits fix(db): optimize Project backfill and repair archived workflows Oct 13, 2026
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 4 files

Confidence score: 5/5

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

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; the previous repair-retry issue is fixed and no new actionable issues were found.

Summary

This PR increases backfill batches, bulk-loads existing Project evidence, and automatically archives active workflows inside archived workspaces.

  • New Project families now move in larger batches.
  • Archived workspaces now archive workflows still marked active.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Discover Project backfill] --> B{Archive repairs needed?}
  B -- Yes --> C[Repair workflows in bounded transactions]
  C --> D{Repair lock busy?}
  D -- Yes --> E{Attempts remain?}
  E -- Yes --> C
  E -- No --> F[Stop without completion receipt]
  D -- No --> G[Rediscover]
  G --> H[Assign Project batches]
  B -- No --> H
  H --> I[Verify and enforce membership]
  I --> J[Record completion]
Loading

Reviews (3) · Last reviewed commit: "fix(db): retry busy Project archive repa..." · Reviewed by Greptile

Comment thread packages/db/script-migrations/0032_project_membership.ts Outdated
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 4 files

Confidence score: 5/5

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

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

@mzxchandra
mzxchandra marked this pull request as ready for review October 13, 2026 06:00
@mzxchandra
mzxchandra merged commit d7ec406 into staging Oct 13, 2026
41 of 42 checks passed
@mzxchandra
mzxchandra deleted the codex/project-backfill-bench branch October 13, 2026 06:00

This branch was successfully deployed

1 active deployment
Preview — 358283e3 Deployed Oct 13, 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