Repository navigation
Description
Summary
Following the removal of PauseActor in favor of SuspendActor (with DURABILITY_MODE_ASYNCHRONOUS as the default and DURABILITY_MODE_SYNCHRONOUS also retaining node-local snapshots after #2883), RevertActor still relies on legacy PAUSED assumptions where a node-local / PENDING snapshot is treated as uncommitted state to be destroyed rather than a valid snapshot to revert to.
This causes two concrete bugs in cmd/ateapi/internal/controlapi/workflow_revert.go:
Bug 1: Reverting a RUNNING or CRASHED actor destroys its latest snapshot if that snapshot is still node-local / PENDING
When an actor is suspended with the default SuspendActor mode (DURABILITY_MODE_ASYNCHRONOUS), resumed, and then reverted while atelet's background upload of that snapshot is still PENDING (default upload delay is 5 minutes), RevertActor destroys the snapshot it should be reverting to:
CreateActor→ResumeActor→SuspendActor(default async mode). This mints generationGinstatus.snapshotswithlocality = <node>anddurable_snapshot.status = SNAPSHOT_STORAGE_STATUS_PENDING.ResumeActorrestores the actor on<node>from generationG's node-local snapshot (ACTOR_STATE_RUNNING). The actor then either continues running or entersACTOR_STATE_CRASHEDbefore generationG's background upload finishes.- Calling
RevertActorto roll the actor back to generationG:ensureWorkerDiscarded(cmd/ateapi/internal/controlapi/workflow_revert.go:188-209) callsensureAteletTerminated→ ateletTerminate(cmd/atelet/main.go:1745-1755), which callss.snapshots.Forget(actorUID)(canceling the background upload) andsnapshottracker.PruneLocalCheckpoints(deleting generationG's node-local checkpoint files on disk).ensureInProgressSnapshotDiscarded(cmd/ateapi/internal/controlapi/workflow_revert.go:220-258) deletes from object storage every snapshot withdurable_snapshot.status == SNAPSHOT_STORAGE_STATUS_PENDING, which includes generationG's durable upload.ensureRevertedFinalized(cmd/ateapi/internal/controlapi/workflow_revert.go:289) callspruneSnapshots(toUpdate.Status, nil), which drops generationGfromstatus.snapshotsbecausepruneSnapshotsonly retainslocal(passed asnil) and the latestCOMPLETEDdurable snapshot.
Result: Instead of reverting the RUNNING / CRASHED execution back to generation G (whether local or durable), RevertActor permanently deletes generation G and rolls the actor back to an even older COMPLETED durable snapshot (or leaves status.snapshots empty so the next ResumeActor cold-boots from the template).
Even when generation G is already COMPLETED durable and also has a node-local copy (locality != ""), RevertActor's Terminate call deletes the node-local checkpoint on atelet and clears locality / assigned_node, forcing the next ResumeActor to restore from remote object storage instead of the local copy.
Bug 2: isRevertable on ACTOR_STATE_SUSPENDED depends on internal upload/detach timing
In cmd/ateapi/internal/controlapi/workflow_revert.go:46-50:
func isRevertable(actor *ateapipb.Actor) bool {
state := actor.GetStatus().GetState()
return slices.Contains(revertableStates, state) ||
(state == ateapipb.ActorState_ACTOR_STATE_SUSPENDED && latestSnapshotIsLocal(actor.GetStatus()))
}Because both synchronous SuspendActor (since #2883) and asynchronous SuspendActor now leave a SUSPENDED actor with locality != "" until detach, calling RevertActor on an ACTOR_STATE_SUSPENDED actor produces three different behaviors depending on internal background upload and detach timing:
- Before background upload completes (
locality != "",durable_snapshot.status == PENDING):RevertActoris accepted, deletes generationG(both node-local andPENDINGdurable), and rolls the actor back to generationG-1(or to no snapshot ifGwas the first suspend). - After sync
SuspendActoror after async background upload completes, before detach (locality != "",durable_snapshot.status == COMPLETED):RevertActoris accepted (becauselatestSnapshotIsLocalis stilltrue), does not revert to generationG-1(whichSuspendActoralready pruned/released orpruneSnapshots(toUpdate.Status, nil)drops in favor of generationG), and merely deletes the node-local cache copy on atelet while keeping generationG'sCOMPLETEDdurable snapshot. - After detach (
locality == "",durable_snapshot.status == COMPLETED):RevertActoris rejected withFAILED_PRECONDITION.
Expected Behavior
- Reverting an actor should revert to its target snapshot smoothly regardless of whether that snapshot is currently node-local (
PENDINGupload) orCOMPLETEDdurable, without destroying a valid node-local snapshot from a completedSuspendActor. - The precondition and semantics of
RevertActoronACTOR_STATE_SUSPENDEDshould not depend on whether atelet has finished its background upload or detached the local copy.
Activity
chw120 commentedon Oct 28, 2026
Another case of Bug 1, on the #3094 path: a revert deletes a complete upload after a failed resume.
Generation 1 is durable. Generation 2 is local on node-3 with a PENDING upload.
recordRestoredUploadinfinalizeRunning).ensureInProgressSnapshotDiscarded). The next resume falls back to generation 1, and generation 2 is lost.Only a
NotFoundfrom Restore (crashMessageLocalSnapshotNodeGone) shows the upload is missing. After any other failure, the upload may be the only copy of generation 2.Neither open PR covers this. #3041 clears the locality of snapshots on the deleted node, then deletes the upload. #3079 only records an upload that the atelet on the assigned node reports, and the uploading atelet was on node-3.
I added the test below to
cmd/ateapi/internal/controlapi. It fails on main (7a19374) and on #3041 (40dc5fc):Test
On #3041 (40dc5fc), replace
SnapshotStorageState_SNAPSHOT_STORAGE_STATE_COMPLETEDwithSnapshotStorageStatus_SNAPSHOT_STORAGE_STATUS_COMPLETED, the enum's name before main renamed it.cc igooch (#3094) Luomu (@cloudonly) (#3041) Zoe Zhao (@zoez7)