Repository navigation
Scheduler: runs, jobs, leases, retries and cancellation - #3
Closed
KristiforMilchev wants to merge 1 commit into
Closed
KristiforMilchev wants to merge 1 commit into
KristiforMilchev wants to merge 1 commit into
Conversation
- Runs and jobs in PostgreSQL. A run is planned from the pipeline file and the event; jobs wait for their needs, are skipped when a need fails, and the run closes when nothing can change any more - Jobs go to workers matching pool, OS, architecture, image and labels, up to each worker's capacity. Claiming is one statement with FOR UPDATE SKIP LOCKED, so several controllers never assign a job twice - Leases renewed by heartbeats; expired leases requeue the job, up to 3 attempts. Jobs a disconnected worker never started go back at once without using an attempt. Updates from a worker that no longer holds a job are ignored and answered with a cancel - Cancel from any process: the serving controller stops the jobs on the workers it holds - controller run create|list|show|cancel; serve runs the scheduler - Worker client: stopping now ends the stream at once (Receive ignored context cancellation and waited ~400ms for the controller), and HTTP/2 pings detect a controller that vanished - Integration tests with fake workers built on the real client, checked by breaking the queries on purpose Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Third part of milestone M1. Stacked on #2: it targets
controller-connectso the diff shows only the scheduler, and GitHub retargets it tomainonce #2 is merged.What it does
controller run createplans a pipeline for an event and stores the run and its jobs. Jobs wait for theirneeds, are skipped when a need fails, and the run closes as succeeded, failed or cancelled.FOR UPDATE SKIP LOCKEDplus a re-check after the lock, so two controllers can't assign the same job.Worker client fixes found by these tests
Receiveignored context cancellation. It's now about 0.1ms, with a regression test.Tests: fake workers built on the real worker client, against a real controller and PostgreSQL. They cover:
needs;To check the tests catch real bugs, I broke the queries on purpose (ignore pool, ignore labels, never skip blocked jobs, no locking). Each change made a test fail; the labels case only did after I added a test for it.
🤖 Generated with Claude Code