---
title: "Server Failover"
description: "What runs again when a Dex Server node fails over or loses an ASYNC Step's start or result, and what you do about it."
canonical_url: "https://docs.superdurable.io/production-operations/server-failover/"
source: "docs/content/concepts/failover-and-deploys.mdx"
locale: "en"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Server Failover

A Step whose result Dex durably committed stays finished after a Dex Server
failover. An
attempt in flight fails and can run again. ASYNC progress that Dex had not
saved yet can be undone.

| Event                                                                                                                                          | What runs again                                                                                                                    | What you do                                                                                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [A Dex Server node fails over](https://docs.superdurable.io/production-operations/server-failover.md#a-dex-server-node-fails-over)             | A durably started attempt still in flight fails and counts against its retry policy. Another attempt runs if the policy allows it. | Give external calls an [idempotency key](https://docs.superdurable.io/concepts/step.md#idempotency-keys). |
| [An ASYNC Step's start is lost](https://docs.superdurable.io/production-operations/server-failover.md#an-async-steps-start-or-result-is-lost)  | The same attempt number, maybe on a different snapshot                                                                             | Keep ASYNC methods idempotent; use SYNC when the Step must see one snapshot.                              |
| [An ASYNC Step's result is lost](https://docs.superdurable.io/production-operations/server-failover.md#an-async-steps-start-or-result-is-lost) | That Step and later work up to the next SYNC Step                                                                                  | Make that Step and the work before the next SYNC Step safe to repeat.                                     |

<a id="a-dex-server-node-fails-over"></a>

## A Dex Server node fails over

When the active node crashes, a standby takes over after the lease expires, if
one is configured and can reach the store. If a standby takes over, it recovers
durable state. A durably started attempt still in flight fails and counts
against its retry policy, even if its Worker kept running, because the new node
cannot learn whether it finished. Another attempt runs if the policy allows it.
A graceful step down releases the lease, so a standby takes over at once.
[Lease](https://docs.superdurable.io/reference/server/high-availability.md#lease) gives the timings.

If the original Worker finishes later, Dex ignores its result, as
[Attempts and Worker failures](https://docs.superdurable.io/reference/server/workers.md#attempts-and-worker-failures)
describes.

<a id="agent-tools-and-server-upgrades"></a>

### Agent tools and server upgrades

An agent's single-attempt tool that was running during a failover ends as
`outcome_unknown`, because its attempt reached a Worker and then failed. See
[Tool call outcomes](https://docs.superdurable.io/reference/agents/failures.md#tool-call-outcomes).

Some server upgrades stop every server process, which fails in-flight attempts
the same way. Before such an upgrade, stop the Workers gracefully. Then stop
and upgrade the server, and start the Workers again. While no Worker runs,
Steps wait in the queue and RPCs fail. See
[Upgrades](https://docs.superdurable.io/reference/server/upgrades.md).

<a id="an-async-steps-start-or-result-is-lost"></a>

## An ASYNC Step's start or result is lost

Dex moves a Flow on before it saves an ASYNC Step's start and result. If the
node crashes before the start is saved, the same attempt number runs again,
uses no retry, and can read a different state snapshot. If it crashes before
the result is saved, later work up to the next SYNC Step can run again too.
Keep ASYNC methods idempotent.
[SYNC and ASYNC Steps](https://docs.superdurable.io/evaluate-dex/correctness-and-expressiveness/advanced-step-guarantees.md#sync-and-async)
explains why the repeat stops there.

## Next

- [Deploy Code Changes](https://docs.superdurable.io/production-operations/deploy-code-changes.md): what a deploy changes, and what runs again when a Worker stops.
- [Step guarantees](https://docs.superdurable.io/concepts/step.md#guarantees)
- [Limits](https://docs.superdurable.io/evaluate-dex/limits.md)
