Repository navigation
Description
ax suspend has a fixed 15 s deadline (cmd/ax/main.go:834). If the workspace snapshot takes longer to upload, the deadline cancels the suspend inside Substrate. The next commands all succeed, but the task comes back from an older snapshot and the new workspace files are gone.
I used only ax commands. Marker file A was in an earlier snapshot. Then I wrote marker B and a 3 GiB random file to /workspace.
| Step | Exit | AX phase | Substrate actor |
|---|---|---|---|
ax suspend task T |
DeadlineExceeded after 15 s |
Running | SUSPENDING |
ax resume task T |
error, actor is SUSPENDING | Failed | SUSPENDING |
ax suspend task T |
0 | Suspended | CRASHED |
ax resume task T |
0 | Running | RUNNING |
After the last step A is still there, but B and the 3 GiB file are gone. The actor stayed SUSPENDING for at least 5 minutes after the first step, so waiting does not help.
Why
- ax-server passes the request context to
SuspendActor(reconciler.go:196), so the CLI deadline cancels the Substrate workflow. At that point ateom has already checkpointed and removed the sandbox, and the cancel stops the upload. Substrate keeps no snapshot files after a failed upload (substrate#362) and leaves the actor SUSPENDING for a retry. - The retried suspend runs
runsc pauseon the removed sandbox (exit status 128) and Substrate crashes the actor.reconciler.go:196-203only logs theSuspendActorerror and sets the phase to Suspended, so the CLI reports success. - On the next resume
EnsureActorfinds the crashed actor and callsRevertActor(internal/substrate/client.go:326-336). The only trace is a log line,existing actor is crashed, reverted to its last snapshot.
The status write after a CLI deadline also uses the cancelled context and is dropped. That is why the task stays Running in step 1 although the actor is SUSPENDING. I saw the same after a slow resume, where the task stayed Suspended while the actor ran.
Size
In my lab 512 MiB suspends in 7 to 10 s and 1 GiB in 11 to 16 s, so 1 GiB sometimes passes the deadline and leaves the task stuck. Data loss happened in 3 of 3 trials with 1.5 GiB on the older stack and 3 of 3 with 3 GiB on Substrate main. A 512 MiB control kept all files. kubectl ate suspend actor has no 15 s deadline and completes a 1.5 GiB suspend in about 16 s.
Possible fixes
Running the Substrate lifecycle calls on a context that a client disconnect cannot cancel, with its own timeout, prevents the loss. A longer or configurable CLI deadline also helps. Returning the SuspendActor error and not reverting a crashed actor silently would make a failure visible to the user.
Environment
A kind cluster on Docker Desktop, Apple Silicon. Same sequence on two stacks.
- google/ax
ac23328with Agent Substrate1d7ca8c - google/ax
be7b1a8(the Task creation fails on Substrate 6a35150 and later: AX still sends the removed snapshot_config.on_resume #443 fix from Ethereal49/ax) with Agent Substrate main0b91488d
Activity
eren23 commentedon Oct 7, 2026
I put a fix on my fork since this repo does not take outside PRs. It is one commit on top of ac23328.
eren23@6921ec5
context.WithoutCancel(ctx)with a 10 minute limit. A client that gives up no longer cancels the Substrate call, and the status write is not dropped.RedisLockerrenews the lease every TTL/3 while the lock is held. Without this, a long suspend outlives the 30 s lease and the next command for the task gets the lock while the suspend still runs.ax suspendandax resumewait 5 minutes instead of 15 s.Two new tests fail without the fix and pass with it. One cancels the client context while a suspend is in the reconciler. The other holds a
RedisLockerlock for more than three TTLs against a real Redis and skips unlessAX_TEST_REDIS_ADDRis set.I reran my lab with this commit and Substrate 1d7ca8c, 3 GiB workspace, same marker check as above.
DeadlineExceeded, all files keptax suspendkilled after 3 sBefore the fix this size lost B and the blob in 3 of 3. In one trial a suspend held the lock for 43 s and the overlapping resume waited for it instead of taking the lock at 30 s.
I did not touch the silent revert itself, the swallowed
SuspendActorerror atreconciler.go:196-203and theRevertActorcall inEnsureActor. I can add that too if you want it in the same change.Update. I added a second commit, eren23@aaf9118, that returns the
SuspendActorerror and sets the task to Failed instead of reporting Suspended. With both commits, an object store outage, an ax-server restart or a SIGKILL of atelet during the upload still loses the workspace (that part is substrate#362), butax suspendnow fails instead of reporting success. My lab chaos run with worker and ax-server crashes shows no regressions.Report a failed Substrate suspend instead of Suspended
feat(task): add spec.budget.activeDeadline to bound a task's running …
feat(task): add spec.budget.activeDeadline to bound a task's running …