Demo · crash recovery
Durable workflow crash recovery with SQLite
This is a scripted replay of the real orch8 demo crash-recovery command. It leaves a workflow instance mid-flight, simulates the engine dying by dropping its only database connection, then restarts against the same database file and reclaims the orphaned work.
Recorded engine execution
- Last persisted state
- Running. The fixture seeds an update time ten minutes before recovery.
- Interruption
- The storage connection closes. No interruption timestamp was recorded.
- Reclaim
- Recovery changes one instance to scheduled. Reclaim duration was not recorded.
- First progress after reclaim
- The run is eligible for a worker claim. This fixture ends before a worker claims it.
- Create a real SQLite database
A fresh file-backed database in a temp directory, with a sequence and one workflow instance for tenant crash-demo.
- Leave the instance mid-flight
The instance is written in the running state with its last update ten minutes ago, as if a worker had claimed it and never reported back.
- Simulate the crash
The only storage connection pool is dropped without any cleanup, which simulates the engine process disappearing mid-run. No real process is killed.
- Restart and recover
A new storage handle opens the same file, as a restarted engine would, and runs the engine's stale-instance recovery with a 60-second threshold.
- Check the invariant
The command exits with an error unless exactly one instance was reclaimed and it is back in scheduled, ready to be claimed again.
orch8 demo crash-recovery
$
$ orch8 demo crash-recovery Crash recovery completed instance: <first-run-id> state: running -> scheduled reclaimed: 1 $ orch8 demo crash-recovery --output json { "database": "<temporary-directory>/crash-recovery.db", "instance_id": "<second-run-id>", "before_restart": "running", "recovered": 1, "after_restart": "scheduled" }
- 1
Create a real SQLite database
A fresh file-backed database in a temp directory, with a sequence and one workflow instance for tenant crash-demo.
- 2
Leave the instance mid-flight
The instance is written in the running state with its last update ten minutes ago, as if a worker had claimed it and never reported back.
- 3
Simulate the crash
The only storage connection pool is dropped without any cleanup, which simulates the engine process disappearing mid-run. No real process is killed.
- 4
Restart and recover
A new storage handle opens the same file, as a restarted engine would, and runs the engine's stale-instance recovery with a 60-second threshold.
- 5
Check the invariant
The command exits with an error unless exactly one instance was reclaimed and it is back in scheduled, ready to be claimed again.
Read the terminal transcript
orch8 demo crash-recovery
Crash recovery completed
instance: <first-run-id>
state: running -> scheduled
reclaimed: 1
orch8 demo crash-recovery --output json
{
"database": "<temporary-directory>/crash-recovery.db",
"instance_id": "<second-run-id>",
"before_restart": "running",
"recovered": 1,
"after_restart": "scheduled"
}The output comes from two runs of Orch8 0.7.1 built from the engine main branch on September 26, 2026. Placeholders replace the generated instance IDs and local database path. The animation respects your reduced-motion setting.
Run it yourself
The demo needs no server, database, or network. It creates a throwaway SQLite file in a temp directory.
The demo crash-recovery subcommand is on the engine's main branch and is not in a tagged release yet (latest: v0.7.1), so build the CLI from source for now. Once it ships, brew install orch8 or the other installers will include it.
It exits non-zero if the recovery invariant fails, so you can also use it as a smoke test in CI.
Read the demo source (demo.rs) ↗git clone https://github.com/orch8-io/engine.git
cd engine
git checkout c487ae114421423929fc82b7c52501eef524c03d
cargo run -p orch8-cli --bin orch8 -- demo crash-recoveryorch8 demo crash-recovery
# machine-readable evidence
orch8 demo crash-recovery --output jsonVerify a committed step across a real restart
In the recorded Orch8 0.7.1 run, the first handler ran once before interruption and did not run again after restart. The next scheduled step ran once after restart, and the first output kept its original ID.
If a provider accepts an external write before the engine saves the receipt, recovery has less evidence. The lost invoice receipt example shows how a blind retry creates a second invoice and how a provider lookup recovers the original receipt.
The restart fixture requires Node.js 20 or newer, Orch8 Server 0.7.1, and free loopback ports 18080 and 15051. It starts a disposable SQLite engine, waits for the first log output, stops its own engine process, and restarts against the same database while the second step is scheduled.
Download the restart verifiernode verify-workflow-restart.mjs /path/to/orch8-server orch8-restart-workflow.json| Workflow step | Engine process | Calls |
|---|---|---|
first | before restart | 1 |
second | before restart | 0 |
first | after restart | 0 |
second | after restart | 1 |
Workflow definition
Select a step in the handler-call table to inspect its definition. The two entries below are the blocks submitted by the restart verifier.
Download the restart workflow (JSON)The verifier supplies a fresh sequence ID, tenant ID, and creation timestamp when it submits this definition.
SHA-256 f029ae89d977355c9149beabf0295e61961a72eea31b96b587a6ec0b7f97e5d3
first step
{
"type": "step",
"id": "first",
"handler": "log",
"params": {
"message": "committed before interruption"
}
}second step
{
"type": "step",
"id": "second",
"handler": "log",
"delay": {
"duration": 8000
},
"params": {
"message": "completed after restart"
}
}The handler calls were 8,055 ms apart. This includes the intentional scheduling delay.
Restart rehearsal timing
A separate run with the checksum-verified 0.7.1 release recorded these offsets from the first committed output. Readiness is the first successful health probe. The time to the second output includes the intentional eight-second delay. Individual claim and handler durations were unavailable.
- First output committed +0 ms View
firstdefinition - Second step schedule observed +5 ms View
seconddefinition - Process kill requested +5 ms Related step:
seconddefinition - Process exit observed +8 ms Related step:
seconddefinition - Restart readiness observed +318 ms Related step:
seconddefinition - Second output committed +8046 ms View
seconddefinition
The release's scheduler regression test seeds a saved output and checks that the scheduler executes only the remaining two steps.
Download the recorded restart evidence (JSON)Read the recorded counts from the command line
The public JSON contains this recorded run. Use curl and jq to print the same rows shown above.
curl -fsSL https://orch8.io/demo/crash-recovery/restart-trace.json |
jq -r '.handlerCalls[] | [.phase, .block, .count] | @tsv'before restart first 1
before restart second 0
after restart first 0
after restart second 1Expected result: the original first output keeps its ID. Engine logs show one call to the first handler before interruption and one call to the second handler after restart. The verifier prints the location of its disposable database, sequence definition, and captured logs.
Recover an interrupted external worker
In this recorded Orch8 0.7.1 run, a separate worker process claimed the second step, saved checkpoint 1, and was killed before completion. A replacement reclaimed the same task and finished from the saved checkpoint. The first output kept its original ID.
- First committed output observed +0 ms View
firstdefinition - Original worker saved its checkpoint +61 ms View
externaldefinition - Original worker process exited +63 ms View
externaldefinition - Replacement acquired the task +3879 ms View
externaldefinition - Completed workflow observed +4008 ms View
externaldefinition
| Attempt | Outcome | Failure | Observed duration |
|---|---|---|---|
| 1. Original claim | Interrupted | Process terminated before completion | Unavailable |
| 2. Replacement claim | Completed | None observed | 129 ms to observed workflow completion |
The gap from observed exit to replacement claim was 3,816 ms. The execution time of the replacement handler alone was unavailable. The local fixture used a 3-second stale-heartbeat threshold and a one-second reaper tick. It performed no external provider calls. The observed timings include polling. To reproduce it, use Node.js 20 or newer, the 0.7.1 server binary, and free loopback ports 18087 and 15057.
node verify-worker-interruption.mjs /path/to/orch8-serverRead the SQLite task reaper and thelease recovery regression test. The test checks that the next claimant receives the saved checkpoint and that the previous owner cannot advance it.
Read the recorded worker reclaim from the command line
The downloaded evidence captures process exit and reclaim as observed by the verifier. Subtract their offsets to get the reclaim gap shown above.
curl -fsSL https://orch8.io/worker-interruption-recorded.json |
jq '{checkpointSeq, sameTaskReclaimed, firstOutputRetained, savedExternalOutputs,
reclaimDelayMs: (.offsetsMs.reclaimed - .offsetsMs.interruptionObserved)}'{
"checkpointSeq": 1,
"sameTaskReclaimed": true,
"firstOutputRetained": true,
"savedExternalOutputs": 1,
"reclaimDelayMs": 3816
}What do the public restart recordings prove?
The Orch8 0.7.1 recordings show two recovery boundaries. The Engine restart preserves a committed output while the next step is scheduled. In the separate worker interruption, the Engine stays up and a replacement worker reclaims the task from a saved checkpoint.
The recording demonstrates SQLite stale-instance recovery. It verifies that one orphaned instance moves from running to scheduled and becomes eligible for a new claim. The fixture has no workers or external side effects.
Both fixtures use local handlers. If an external operation was in flight and its receipt was never saved, reconcile the provider outcome before retrying. See the lost invoice receipt example.
Now try it with your own workflow
Run a workflow locally with SQLite, then use the worker recovery checklist to test lease loss and ambiguous external responses.
Run the quickstart