Add state migrations and reduce Postgres scheduling overhead - #1
Open
rorylshanks wants to merge 1 commit into
Open
Add state migrations and reduce Postgres scheduling overhead#1rorylshanks wants to merge 1 commit into
rorylshanks wants to merge 1 commit into
Conversation
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.
Large queues currently sort JSON-derived sizes for rewrite claims, load whole jobs to choose compaction work, and repeat maintenance and progress writes across workers. This adds indexed scheduling columns and moves selection and aggregation into Postgres to reduce that work.
partforge migratewith numbered, transactional migrations and a version ledger. Adopt existing hand-created tables, backfill scheduling columns, and build indexes; repeat runs are a no-op and failures roll back together. State clients check the schema version at startup.FOR UPDATE SKIP LOCKED. Preserve job, destination, and explicit partition filters; remove the idle-partition preference.worker -once.Rollout: stop workers and pause uploads/state-changing admin commands, run the new binary's
partforge migratewith the deployment's database settings, then start the new workers. Backfills and index builds hold table locks. Existing parts, progress, and lineage are retained. Direct SQL state changes must also maintain the derived columns.Validation:
go mod tidy,go test ./...with PostgreSQL integration tests enabled,go vet ./..., and./e2e/run.shpassed. Tests cover migration rollback/backfill/idempotency, concurrent claims, ownership, scheduling-column consistency without triggers, and ordered query plans with 20,000 parts across 10 jobs. This is not a 2,000-worker load-test result.