Repository navigation
feat(orchestrator): system/pipeline_run.ended_at run annotation - #391
Open
morgan-wowk wants to merge 1 commit into
Open
morgan-wowk wants to merge 1 commit into
morgan-wowk wants to merge 1 commit into
Conversation
Mark a pipeline run as ended with a system-owned annotation so callers can ask "is this run still running?" with an indexed annotation lookup instead of aggregating execution statuses. - An after_flush listener writes system/pipeline_run.ended_at (ISO timestamp) in the same transaction as the execution status change that ends the run's last container execution, and removes it if an execution leaves an ended status. - Add a (key, value) index on pipeline_run_annotation, created on startup for existing databases, so key/value reverse lookups use an index. - Allow key_exists filtering on the new system key. Runs that ended before this change carry no annotation (no backfill).
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.
Adds a system-owned run annotation,
system/pipeline_run.ended_at. It's written when a run's last container execution ends, so "is this run still running?" becomes an indexed annotation lookup instead of a status aggregation. The first consumer is the triggermax_concurrencycap in oasis-backend: https://github.com/Shopify/oasis-backend/pull/710sequenceDiagram participant O as Orchestrator participant S as Session (after_flush) participant DB as pipeline_run_annotation O->>S: last execution → SUCCEEDED / FAILED / … S->>S: every container execution in the run ended? S->>DB: INSERT system/pipeline_run.ended_at = <ISO time> Note over O,DB: same transaction as the status change O->>S: execution leaves an ended status S->>DB: DELETE system/pipeline_run.ended_atChanges
container_execution_statusset listener flags executions that cross into or out of an ended status. A newafter_flushlistener reconciles the annotation for the affected runs using Core SQL on the session connection, so it's atomic with the node change and idempotent.(key, value)index onpipeline_run_annotation, created on startup for existing databases. Every existing index leads withpipeline_run_id, sokey = … AND value = …was a full index scan on MySQL (EXPLAIN type=index→refwith this index).key_existsfiltering is allowed on the new key.not key_exists system/pipeline_run.ended_atlists the runs that are still running.Notes
orchestrator_sqlis imported, which means the orchestrator process. A terminal status set through the admin status route on the API process doesn't write it.system/, so users can't set or delete it through the annotation API.Testing
tests/test_pipeline_run_ended_at.pycovers:With the listener removed, the five positive tests fail.
The full suite passes on Python 3.13 and 3.10 (540 tests).
🤖 Generated with Claude Code