Skip to content

ax suspend of a large workspace can lose the workspace while every command reports success #453

Open

Description

@eren23

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

  1. 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.
  2. The retried suspend runs runsc pause on the removed sandbox (exit status 128) and Substrate crashes the actor. reconciler.go:196-203 only logs the SuspendActor error and sets the phase to Suspended, so the CLI reports success.
  3. On the next resume EnsureActor finds the crashed actor and calls RevertActor (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.

  1. google/ax ac23328 with Agent Substrate 1d7ca8c
  2. 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 main 0b91488d

Activity

  1. eren23 commented on Oct 7, 2026

    @eren23
    Author

    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

    1. Once a task handler holds the task lock, it runs on 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.
    2. RedisLocker renews 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.
    3. ax suspend and ax resume wait 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 RedisLocker lock for more than three TTLs against a real Redis and skips unless AX_TEST_REDIS_ADDR is set.

    I reran my lab with this commit and Substrate 1d7ca8c, 3 GiB workspace, same marker check as above.

    CLI Trials Result
    old, 15 s deadline 3 every first suspend hit DeadlineExceeded, all files kept
    new, ax suspend killed after 3 s 2 server finished the suspend about 40 s later, all files kept
    new, 5 min 2 every step exit 0, all files kept

    Before 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 SuspendActor error at reconciler.go:196-203 and the RevertActor call in EnsureActor. I can add that too if you want it in the same change.

    Update. I added a second commit, eren23@aaf9118, that returns the SuspendActor error 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), but ax suspend now fails instead of reporting success. My lab chaos run with worker and ax-server crashes shows no regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions