Skip to main content

Server Failover

View as Markdown

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.

EventWhat runs againWhat you do
A Dex Server node fails overA 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.
An ASYNC Step's start is lostThe same attempt number, maybe on a different snapshotKeep ASYNC methods idempotent; use SYNC when the Step must see one snapshot.
An ASYNC Step's result is lostThat Step and later work up to the next SYNC StepMake that Step and the work before the next SYNC Step safe to repeat.

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 gives the timings.

If the original Worker finishes later, Dex ignores its result, as Attempts and Worker failures describes.

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.

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.

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 explains why the repeat stops there.

Next