Sulat.com / Writing on AISaturday, December 5, 2026
Enter →
Agent Engineering/5 December 2026

What durable execution does when a worker is killed

Temporal's guide defines durable execution as crash-proof execution. I killed a worker, then the server, then changed the code mid-run to see what survives.

Temporal logo in 3D beside a workflow surviving a crashed server, durable execution
Illustration: Sulat, featuring the Temporal logo

At a glance

  • Temporal's guide defines durable execution as code that survives crashes, because a workflow's progress is recorded as an event history that a new worker replays.
  • When I killed the worker during step C, the server waited out the 30-second activity timeout, a new worker re-ran C, and the workflow finished with all five results.
  • After I killed the server and the worker during a timer, the workflow resumed from the same database file and sent all three notices, the second one six seconds late.
  • Adding a step to the code while a workflow was running gave Temporal a shifted set of results with no error, and step C ran twice.
  • DBOS gets the same recovery from a library and a database, but something has to relaunch the process, which took about a second in my test.

Temporal’s Tom Wheeler has published a guide to what durable execution is. His definition is crash-proof execution: a program’s progress is recorded, so after a crash, a restart or an outage it carries on from the step it reached instead of starting again. I built the guide’s example, killed the processes underneath it, and recorded what came back.

Two kills recovered cleanly. A code change made while a workflow was running did not, and Temporal raised no error when it went wrong.

What the guide says

The guide boils the idea down to four traits. The code is crash-proof, so a failure part-way through doesn’t lose the work done so far. A workflow’s history of events is saved and replayed to rebuild its state. Timers and sleeps are durable, so a workflow can wait days without holding a process open. Local variables survive too, because replay rebuilds them.

Infographic: four traits of durable execution, crash-proof, replay, durable timers, kept variables
Temporal’s guide boils durable execution down to four traits.

How it works underneath

In Temporal, your code runs in workers that poll a task queue on the Temporal server. The workflow function decides what happens next, and each side effect, such as an API call, runs as an activity. The server writes every step to an event history. When a worker dies, a new one picks the workflow up and replays that history: steps that already finished return their recorded results instead of running again, and the step that was in flight runs again.

That replay is why workflow code has to be deterministic, and why an activity runs at least once rather than exactly once.

Diagram: workflow crashes at step C, replays history, resumes at step C, durable execution
After a crash, the saved history lets the workflow resume at the step it reached.

What I ran

Everything ran on one Linux machine with 4 vCPUs (Intel Xeon at 2.30 GHz), 15 GiB of RAM, a 252 GB disk and Ubuntu 24.04. The Temporal dev server, the workers and the client all shared it. I used Temporal CLI 1.10.1 (server 1.32.2), the Python SDK temporalio 1.37.0 and Python 3.13, with the server’s SQLite file as its store.

The app has two workflows. FiveSteps runs five six-second activities, A to E, with a 30-second timeout each, and returns the name of the process that finished each one. Notifier sleeps for 5, 10 and 15 seconds in turn, standing in for days, and records a notice after each.

Code
import asyncio, os, sys, time, datetime
from datetime import timedelta
from temporalio import activity, workflow
from temporalio.client import Client
from temporalio.worker import Worker

LOG = os.environ.get("RUNLOG", "run.log")

def log(msg):
    with open(LOG, "a") as f:
        f.write(f"{time.strftime('%H:%M:%S')} pid={os.getpid()} {msg}\n")

@activity.defn
async def step(name: str) -> str:
    log(f"activity {name} started")
    await asyncio.sleep(6)
    log(f"activity {name} finished")
    return f"{name}-done-by-{os.getpid()}"

@workflow.defn
class FiveSteps:
    @workflow.run
    async def run(self) -> list[str]:
        results = []                      # a plain local variable
        for n in ["A", "B", "C", "D", "E"]:
            results.append(await workflow.execute_activity(
                step, n, start_to_close_timeout=timedelta(seconds=30)))
        return results

@workflow.defn
class Notifier:
    @workflow.run
    async def run(self, user: str) -> list[str]:
        sent = []                         # survives the crash too
        for i in [5, 10, 15]:             # seconds standing in for days
            await asyncio.sleep(i)        # durable timer inside a workflow
            sent.append(f"notice after {i}s to {user}")
        return sent

async def main():
    mode = sys.argv[1]
    c = await Client.connect("localhost:7233")
    if mode == "worker":
        log("worker up")
        async with Worker(c, task_queue="q", workflows=[FiveSteps, Notifier], activities=[step]):
            await asyncio.Event().wait()
    elif mode == "start":
        wf = {"five": FiveSteps.run, "notify": Notifier.run}[sys.argv[2]]
        args = ["sam"] if sys.argv[2] == "notify" else []
        h = await c.start_workflow(wf, *args, id=sys.argv[3], task_queue="q")
        print("started", h.id)
    elif mode == "result":
        h = c.get_workflow_handle(sys.argv[2])
        print("RESULT", await h.result())
if __name__ == "__main__":
    asyncio.run(main())

The server, a worker and a run are started like this:

Code
temporal server start-dev --db-filename dev.db
python app.py worker
python app.py start five five-2
python app.py result five-2

Test 1: kill the worker during step C

I started FiveSteps, waited for step C to begin, then ran kill -9 on the worker. With no worker, the workflow sat at 17 history events. I started a new worker eight seconds later.

Step C didn’t restart straight away. The server held it until the 30-second activity timeout had run out, then gave it to the new worker, which ran C again and carried on to E. The result shows the hand-over: A and B were finished by the first process, and C, D and E by the second.

Terminal log of a Temporal worker kill and recovery, activity retried after timeout
The activity restarted on a new worker after the old one was killed.
Temporal Web UI event history showing activity timeout and retry after worker kill
The event history shows the timeout, then the retry on the new worker.

The log also shows step C starting twice, once on each process, and only the second run finishing. That’s the at-least-once rule in practice: an activity that charges a card or sends an email has to cope with running again.

Test 2: kill the server and the worker during a timer

The harder case takes out the thing that holds the history. I started Notifier, let its first timer fire, and killed the server and the worker together while the second timer was running. I left them down for twelve seconds, longer than the timer had left, then restarted the server on the same database file and started a new worker.

The workflow was still there, and all three notices were sent. The second timer was due about six seconds before the server came back, and it fired at the moment the server restarted, so it was six seconds late. The third timer then ran its full fifteen seconds.

Temporal Web UI showing durable timers firing late after the server restart
Timers survived the server restart and fired late.

Test 3: change the code while a workflow is running

This one isn’t a crash. I started FiveSteps, let steps A and B finish, killed the worker, and started a new worker running a changed version of the code with one extra step, Z, at the front of the list.

Temporal replayed the old history against the new code and matched recorded results to steps by activity type and position, not by the arguments they were called with. The workflow finished with no error and returned six results. Step Z got A’s result, A got B’s, and step C ran twice:

Code
["A-done-by-1005","B-done-by-1005","C-done-by-1096","C-done-by-1096","D-done-by-1096","E-done-by-1096"]

Nothing in the output says the history and the code disagreed. Temporal’s documentation points to Worker Versioning and patching for changing code under running workflows, and this run shows why they exist.

Infographic: adding a workflow step shifts results of running workflows, Temporal replay mismatch
Adding a step mid-flight shifted old runs to the wrong results.
Summary of three crash tests: worker kill, server kill, code change, Temporal durable execution
Two kills recovered cleanly, and the code change gave wrong answers.

The same kill on DBOS

DBOS takes a different route. It’s a library that runs inside your own process and keeps its record of completed steps in a database, so there’s no server to run. I wrote the same five steps with DBOS 3.7.0, using its SQLite option, which its own log says is for development and testing, and killed the process during step C.

Code
import os, sys, time
from dbos import DBOS, DBOSConfig, SetWorkflowID

LOG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "run.log")
def log(m):
    with open(LOG, "a") as f: f.write(f"{time.strftime('%H:%M:%S')} pid={os.getpid()} {m}\n")

cfg: DBOSConfig = {"name": "five", "system_database_url": "sqlite:///dbos.sqlite"}
DBOS(config=cfg)

@DBOS.step()
def step(name: str) -> str:
    log(f"step {name} started"); time.sleep(6); log(f"step {name} finished")
    return f"{name}-done-by-{os.getpid()}"

@DBOS.workflow()
def five():
    results = []
    for n in "ABCDE":
        results.append(step(n))
    return results

if __name__ == "__main__":
    DBOS.launch()
    log("process up")
    if sys.argv[1] == "start":
        with SetWorkflowID("five-1"):
            h = DBOS.start_workflow(five)
        print("started", h.get_workflow_id())
        print("RESULT", h.get_result())
    else:
        time.sleep(3)
        print("RESULT", DBOS.retrieve_workflow("five-1").get_result())

Nothing restarts a killed process on its own, so I launched it again by hand. On launch DBOS logged that it was recovering one workflow, and step C started about a second later. The result was the same shape as Temporal’s: A and B from the first process, C, D and E from the second.

Terminal log of DBOS recovering a killed workflow on restart, durable execution
DBOS resumed the workflow about a second after launch.

The difference is who does the waiting. Temporal’s server held step C until its timeout ran out and handed it to whichever worker was polling. DBOS had no server to hold anything, so recovery began as soon as a process came back.

The wider field

Every engine in this space keeps a journal of what has finished. They differ in where that journal lives and who runs it. Temporal and Restate run a server that your code talks to. Inngest runs a service that calls your functions. DBOS keeps the journal in your own Postgres. AWS Lambda, Cloudflare and Vercel now offer durable workflows as part of their platforms. Temporal Cloud is the hosted version of Temporal, and it bills per Action.

Diagram comparing where durable execution engines keep the event journal: server, database, platform
Engines differ mainly in where the journal lives and who runs it.
EngineWhere your code runsWhere the journal livesLicence or terms
TemporalYour workers poll the Temporal serviceTemporal serverMIT
RestateThe Restate server calls your handlersRestate serverBUSL 1.1
InngestInngest calls your functionsInngest serviceSSPL with delayed Apache 2.0
DBOSInside your own process, as a libraryYour PostgresMIT
AWS Lambda durable functionsOn LambdaAWSManaged service
Cloudflare WorkflowsOn WorkersCloudflareManaged service
Vercel WorkflowsOn VercelVercelManaged service
Sources: each project’s licence file and documentation.

What the guide doesn’t cover

The guide explains the idea well, and my first two tests behaved the way it says. It doesn’t walk through versioning, and that’s where my third test went wrong without a sound. It also doesn’t dwell on the other cost of replay: because an activity runs at least once, every activity that touches the outside world needs to be safe to run twice.

So durable execution protects against a crashed process, a dead server and a long wait. It doesn’t protect against a deploy that changes the shape of a workflow that’s already running, or against an activity that can’t tolerate a second run. Those two stay with whoever writes the code.