Skip to content

fix(server): make same-pod attempt start idempotent (#1001) - #1026

Merged
athvin merged 2 commits into
mainfrom
issue/1001-idempotent-start
Nov 9, 2026
Merged

athvin merged 2 commits into
mainfrom
issue/1001-idempotent-start

Conversation

@athvin

@athvin athvin commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1001

🚧 Claimed by an agent session — 2026-11-09T05:48:41Z, session Codex:01a1be03-fa4f-7c42-82b6-91e1838f928f on Mac.
The claim is this open draft PR: closing it releases the ticket.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Make the declared attempt-start transition return the existing running row when the same pod retries. Preserve its original identity and timestamps; keep the live attempt and Kubernetes Job fences.

Why

A lost 200 after a committed start currently becomes a terminal 409 on retry, so the executor can report stale_start for a pod that started successfully.

Proof

  • make check passed locally on cba2d9e5 and again after rebasing on current main at 05c73e51 (full backend gate).
  • The focused pg_task_instances test passed against isolated PostgreSQL 16; er-entity verify found 145 generated files current and every statement passing E0xx.
  • Rust CI 42572887686 passed on the rebased head, including both Postgres server shards. Frontend, infra, devcontainer, and the PR contract also passed. The first run had unrelated sccache release-download HTTP 504 failures; rebasing and rerunning cleared them.

Risk & rollback

Risk: the start statement also handles running rows from the same pod; the Postgres regression checks the boundary and the 409 fences.
Rollback: revert the eventual squash merge commit.

Post-merge ledger

Closed by: Codex · session Codex:01a1be03-fa4f-7c42-82b6-91e1838f928f on Mac-26 · 2026-11-09T07:22:40Z

  • main is green with this change on it — squash cd4ddd50a9b8cc6b596d43b38e1bfc65ee24b886 is on origin/main; its rust run 42574267648, frontend 42574267646, infra 42574267691, and devcontainer 42574267535 all passed. The 30-minute watch ended at 2026-11-09T07:08:16Z without a new failure. Current main at ef9ab24f descends from this squash; its frontend, infra, and devcontainer runs passed, and its Rust run was queued at closure.
  • images built, or correctly never ran because nothing that goes into
    an image changed: run 42574267609 built and pushed er-api for cd4ddd50; unchanged er-web was skipped.
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: run 42574724930 logged deploying cd4ddd50 and succeeded for prod and dev. Both live er-api Services select blue; both ready web-api-blue deployments run the new API digest bc7d7b5b…. Their running er-server processes emitted er-server listening at 2026-11-09T06:43:29.659483Z (prod) and 06:44:11.360985Z (dev).
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: deploy 42574724930 is green. The last scheduled drift run 42570659369 failed before this merge on missing Cloudflare auth (Restore Cloudflare authentication in the scheduled Terraform drift workflow #1030) and a GitHub 504; cluster-objects correctly did not trigger for this Rust-only diff. kind nightly 42575735163 passed on the merge SHA, as did scheduled frontend 42576920853 and Agentic Maintenance 42577146694. Scheduled Rust 42577173686 was still running without a failed job at closure; the required Rust run on the merge SHA had already passed.
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: rust: make same-pod attempt start retry idempotent #1001 is CLOSED, its closure event names PR fix(server): make same-pod attempt start idempotent (#1001) #1026, and its Product Roadmap card reads Done without a manual board edit.
  • follow-ups are open for everything deferred here — numbers: n/a — no work from rust: make same-pod attempt start retry idempotent #1001 was deferred. The pre-existing scheduled drift failure is already tracked by Restore Cloudflare authentication in the scheduled Terraform drift workflow #1030.
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: entities/task_instance/update/start.yaml describes the retry contract, and pg_task_instances.rs pins the lost-response and fence cases in a Postgres regression.

Specific to this change

Context — plan, discoveries, measurements, files

Plan

  1. Extend entities/task_instance/update/start.sql so the queued transition or a running retry from the same pod_uid returns one row under the existing attempt, live, and Kubernetes Job guards. Keep the original identity, started_at, heartbeat, and update timestamps on a replay; update the statement description.
  2. Expand the existing pg_task_instances Postgres scenario: treat the first 200 as lost, retry from the same pod, compare timestamps and stored identity, and verify a different pod, wrong Job, and archived attempt still receive 409.
  3. Regenerate the typed entity statement, run er-entity verify, the Postgres test tier, and root make check; record any environment limitation explicitly.
  4. Review the diff, update this PR with evidence, then land it and close the post-merge ledger.

Discoveries

Measurements

  • er-entity verify: 145 generated files current; every statement passed E0xx.
  • ER_TEST_PG_DSN=… cargo test -p er-server --test main pg_task_instances::the_task_ledger_statements_hold_their_contracts -- --nocapture: 1 passed against isolated Postgres 16.
  • make check: passed on cba2d9e5 and rebased 05c73e51. Run 42570514147 failed on sccache release-download HTTP 504; run 42572887686 passed all Rust jobs on the rebased head.

Files

@athvin
athvin marked this pull request as ready for review November 9, 2026 06:09
@athvin
athvin force-pushed the issue/1001-idempotent-start branch from cba2d9e to 05c73e5 Compare November 9, 2026 06:24
@athvin
athvin merged commit cd4ddd5 into main Nov 9, 2026
45 checks passed
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.

rust: make same-pod attempt start retry idempotent

2 participants