
Invocation ID
Invocations have a unique Invocation ID starting withinv_
. You can find this ID in every place where an invocation is mentioned:
- The invocations page of the Restate UI
- Logs and traces (
restate.invocation.id
), both in Restate and SDKs - In CLI commands such as
restate invocation ls
Lifecycle
Invocations follow a well-defined lifecycle:
Cancel
You can cancel an invocation at any point in its lifecycle. Cancellation has the following characteristics:- Frees held resources
- Cooperates with your handler code to roll back any changes made so far
- Allows proper cleanup
For proper rollback, handlers must include compensation logic to maintain service state consistency. Check the sagas guide.
How Cancellation Works
How Cancellation Works
When an invocation is canceled, Restate propagates the cancellation recursively through the call graph:
- Propagate to leaves: Cancellation first reaches the leaves of the call graph. Restate interrupts any ongoing sleeps, awakeables, or other context actions at those points.
- Throw terminal error: At the cancellation point, Restate throws a terminal error, signaling that normal execution cannot continue.
- Run compensation: The handler runs its defined compensation logic to undo or mitigate side effects.
- Propagate upward: The cancellation response then flows back up the call graph, ensuring that each parent invocation also executes its compensation logic if defined.
Kill
Use kill when cancellation fails (e.g., when endpoints are permanently unavailable). Killing immediately stops all calls in the invocation tree without executing compensation logic. This may leave your service in an inconsistent state. Only use as a last resort after trying other fixes. Note that one-way calls and delayed calls are not killed because they’re detached from the originating call tree.Resume
If an invocation retries for too many times, Restate will pause it. When an invocation is paused, you need to resume it manually:Resuming on a different deployment
Resuming on a different deployment
When resuming, the invocation will run on the same deployment where it started.If the invocation failed due to some bug you fixed on a new/different deployment,
you can override on which deployment the invocation should be resumed:Be aware that if the business logic/flow between the old and the new deployment code differ, once resumed the invocation will start fail with non-determinism errors!