Skip to content

ateapi: Fix various actor workflow races - #1444

Open
Eitan Yarmush (EItanya) wants to merge 2 commits into
agent-substrate:mainfrom
kagent-dev:fix/preserve-crashed-lifecycle
Open

ateapi: Fix various actor workflow races#1444
Eitan Yarmush (EItanya) wants to merge 2 commits into
agent-substrate:mainfrom
kagent-dev:fix/preserve-crashed-lifecycle

Conversation

@EItanya

@EItanya Eitan Yarmush (EItanya) commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Worker deletion can race both lifecycle finalization and the gap between a worker claim and its actor backlink. Preserve CRASHED during resume and suspend finalization, returning FailedPrecondition instead of reporting an invalid successful transition.

When a drained worker still has a claim whose actor backlink is pending, advance the actor's version before deleting the worker. The pending resume write then loses its version check and retains the actor's suspended or paused state and snapshots for retry. If resume wins the version check, deletion returns Aborted and retries against the committed assignment.

Regression tests cover the lifecycle finalization races, both assignment/deletion orderings, snapshot preservation, and avoiding false crash metrics.

Fixes #1443

Validation:

  • PostgreSQL regression tests for both assignment/deletion orderings passed with -race.
  • env -u NO_COLOR make verify in a clean worktree (includes go test -race ./...).

@EItanya
Eitan Yarmush (EItanya) force-pushed the fix/preserve-crashed-lifecycle branch from ca33fa5 to ad92263 Compare September 5, 2026 22:48
A worker claim can commit before resume writes the actor backlink. Advance the actor version when deleting a drained worker with a pending claim so that resume cannot persist a reference to the deleted worker. Preserve suspended and paused state, and retry deletion if resume wins the version check.

Signed-off-by: Eitan Yarmush <[email protected]>
@EItanya Eitan Yarmush (EItanya) changed the title ateapi: preserve crashes during lifecycle finalization ateapi: preserve actor state during worker deletion Sep 5, 2026
@EItanya Eitan Yarmush (EItanya) changed the title ateapi: preserve actor state during worker deletion ateapi: Fix various actor workflow races Sep 5, 2026
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.

[Bug]: Lifecycle finalizers can overwrite a concurrent worker-deletion crash

1 participant