Skip to content

fix: Orchestrator - Respect pipeline run cancellation when the node flag is lost - #390

Open
grigoriipenkin-spec wants to merge 2 commits into
TangleML:masterfrom
grigoriipenkin-spec:grigorii/1316-preserve-cancel-intent
Open

grigoriipenkin-spec wants to merge 2 commits into
TangleML:masterfrom
grigoriipenkin-spec:grigorii/1316-preserve-cancel-intent

Conversation

@grigoriipenkin-spec

@grigoriipenkin-spec grigoriipenkin-spec commented Oct 8, 2026 •

Copy link
Copy Markdown

What

Cancel can be lost for an execution that is PENDING or RUNNING. The cancel API returns 200 but the container keeps running.

The running sweep now votes to terminate a node when the node flag or the flag of its pipeline run is desired_state=TERMINATED.

Why

terminate() commits desired_state=TERMINATED in extra_data of the run and its nodes. The orchestrator can hold an older copy of the node at the same time. When it sets a new status, the status history listener writes the whole extra_data from that old copy and the node flag is gone. The running sweep only read the node flag, so it never terminated the container.

The run flag is not touched by that write, so checking it too keeps the cancel.

Associated Issue

Shopify/ml-infrastructure#1316

Dev Notes

  • No schema change. A dedicated column would stop the node flag from being dropped, but manual migrations are on hold until Alembic.
  • A container execution shared by several runs is still terminated only when every run votes to terminate.
  • Shopify/oasis-backend#754 fixes an Oasis write that could drop the run flag right after submit.
  • Not covered here: the node flag can still be dropped, and nodes without a pipeline run rely on it only. Cache reuse, shared executions and concurrent completion can still end with a non-CANCELLED status after cancel.

Tests

  • Cancel races a stale status write: the node flag is dropped and the container is still terminated.
  • Two runs share one container execution through cache: cancelling one run does not terminate it, cancelling both does.

…lag is lost

A status update from a stale session rewrites the whole ExecutionNode.extra_data
and drops the desired_state flag that the cancel API had just committed. The
running-execution sweep only read the node flag, so the container kept running
after cancel returned success. The sweep now also checks the owning pipeline
run's flag, which the orchestrator never rewrites.

Refs Shopify/ml-infrastructure#1316
@grigoriipenkin-spec
grigoriipenkin-spec requested a review from a team October 8, 2026 18:29
@grigoriipenkin-spec grigoriipenkin-spec changed the title fix: Orchestrator - Do not lose pipeline run cancellation to a stale status write fix: Orchestrator - Respect pipeline run cancellation when the node flag is lost Oct 9, 2026
@grigoriipenkin-spec
grigoriipenkin-spec force-pushed the grigorii/1316-preserve-cancel-intent branch from 4b9a0d8 to c62e2a3 Compare October 9, 2026 14:17
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