Skip to content

fix: explain locality conflicts instead of 'no free workers available'#401

Open
Grant McCloskey (MushuEE) wants to merge 2 commits into
agent-substrate:mainfrom
MushuEE:fix/locality-scheduling-error
Open

fix: explain locality conflicts instead of 'no free workers available'#401
Grant McCloskey (MushuEE) wants to merge 2 commits into
agent-substrate:mainfrom
MushuEE:fix/locality-scheduling-error

Conversation

@MushuEE

Copy link
Copy Markdown
Collaborator

Fixes #398

Note

Based on #399 (both change findFreeWorker); the first commit here is that PR. Review only the second commit, or merge #399 first and this rebases cleanly.

When an actor's latest snapshot is a local checkpoint, findFreeWorker hard-restricts candidates to the node(s) holding it — correctly, since the checkpoint only exists there. But when that restriction eliminates every candidate, the error was the generic no free workers available, which reads as cluster-wide capacity exhaustion and hides the far more serious case where the snapshot's node no longer exists and the actor's checkpointed state is unreachable.

findFreeWorker now returns a workerScan carrying the picked worker plus one flag gathered in its existing single pass (no extra iteration): whether any eligible worker exists on the restricted node(s). The failure message distinguishes:

  • actor's local snapshot is on node(s) [X] but all eligible workers on those nodes are busy
  • actor's local snapshot is on node(s) [X] but no eligible workers exist on those nodes (the node(s) may have been removed)

The status code stays FailedPrecondition, and the generic message is unchanged when no locality restriction is in effect (existing functional tests pass unmodified).

This intentionally does not make the actor schedulable in either case — that requires the snapshot model to retain the external URI alongside local locality, which is part of a separate architecture proposal.

When FinalizePausedStep runs after the worker record is already gone,
the node holding the local checkpoint is unknown. Previously the step
wrote [""] into NodeVmsWithLocalSnapshots, which findFreeWorker treats
as a hard restriction no worker can satisfy - every subsequent resume
fails with 'no free workers available' and the actor is permanently
unschedulable short of boot=true.

Write side: only record the node when it is known; an empty list means
no locality restriction, so the scheduler can still place the actor
(local checkpoints live on the node, so a shuffled retry can land on
the node that holds it).

Read side: findFreeWorker ignores empty entries in the restriction
list, healing actor records already poisoned by the old write path
without a data migration.

Fixes agent-substrate#397
When an actor's latest snapshot is a local checkpoint, findFreeWorker
hard-restricts candidates to the node(s) holding it. When that
restriction eliminates every candidate, the error was the generic
'no free workers available', which reads as cluster-wide capacity
exhaustion - and hides the far more serious case where the snapshot's
node no longer exists and the actor's checkpointed state is
unreachable.

findFreeWorker now returns a workerScan carrying the picked worker
plus one flag gathered in its existing single pass (no extra
iteration): whether any eligible worker exists on the restricted
nodes. The failure message distinguishes:

- all eligible workers on the snapshot's node(s) are busy
- no eligible workers exist on the snapshot's node(s) at all (node
  likely removed)

The status code remains FailedPrecondition; the generic message is
unchanged when no locality restriction is in effect.

Fixes agent-substrate#398
@thockin

Copy link
Copy Markdown
Collaborator

needs rebase

@thockin Tim Hockin (thockin) self-assigned this Jul 8, 2026

@thockin Tim Hockin (thockin) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping me after you rebase

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.

Locality-restricted resume failures report a misleading "no free workers available" error

2 participants