Skip to content

Railgate fault recovery replay

One worker goes down mid-job; a second takes over from the checkpoint and finishes it. Railgate is a governed HTTP and MCP gateway with a durable agent runtime, open source at github.com/riefer02/railgate.

Replay the crash Read the case study
Markdown

Recorded from a local test stack against synthetic records. Timestamps are elapsed time from the start of each scenario; playback pauses for readability.

Worker crash and recovery

The original worker was killed while fetching page two. A healthy replica recovered the same job and finished all three pages.

Runtime journal

Job admitted

The gateway forwarded a report job to the runtime. Postgres holds the queued job.

View captured evidence
{
  "kind": "job_admitted",
  "state": "queued",
  "attempt": 0
}
Runtime journal

First worker claims the job

The first worker begins reading the records under lease 1.

View captured evidence
{
  "kind": "job_started",
  "state": "running",
  "attempt": 1,
  "worker": "runtime-a-0",
  "lease": 1
}
Postgres checkpoint

First page checkpointed

The runtime committed two records' worth of progress and the next cursor before starting the second page.

View captured evidence
{
  "worker": "runtime-a-0",
  "lease": 1,
  "tool": "list",
  "items": 2,
  "limit": 2,
  "pages": 1,
  "cursor": "1",
  "version": 1
}
Docker and upstream observations

Worker killed in flight

The test harness sent SIGKILL while the cursor 1 request was in flight. The original container stayed down through completion.

View captured evidence
{
  "worker": "runtime-a-0",
  "signal": "SIGKILL",
  "cursorsSeen": [
    null,
    "1"
  ],
  "originalContainerRunningAtCompletion": false
}
Runtime journal

Expired lease returns job to the queue

The runtime's lease sweep requeued the job after the original worker stopped renewing its claim.

View captured evidence
{
  "kind": "job_queued",
  "state": "queued",
  "attempt": 1,
  "lastObservedLeaseExpiry": "2026-12-05T15:28:18.38519+00:00"
}
Runtime journal and Postgres

Surviving worker resumes at cursor 1

The second replica claimed the same job under lease 2. Its stored checkpoint still pointed to page two.

View captured evidence
{
  "kind": "job_started",
  "state": "running",
  "attempt": 2,
  "worker": "runtime-b-0",
  "lease": 2,
  "checkpoint": {
    "tool": "list",
    "items": 2,
    "limit": 2,
    "pages": 1,
    "cursor": "1",
    "version": 1
  }
}
Runtime journal and upstream observations

Six records recovered

The surviving worker finished all three pages. The two requests for cursor 1 used the same idempotency key.

View captured evidence
{
  "kind": "job_succeeded",
  "state": "succeeded",
  "attempt": 2,
  "outcome": "list: 6 items across 3 page(s)",
  "upstreamRequests": 4,
  "cursorsSeen": [
    null,
    "1",
    "1",
    "2"
  ],
  "repeatedCursorKeyMatches": true
}

Transient upstream failure

The test upstream returned HTTP 503. Railgate scheduled a retry and the job completed after the test upstream was restored.

Runtime journal

Report job queued

The runtime accepted a new one-page read.

View captured evidence
{
  "kind": "job_admitted",
  "state": "queued",
  "attempt": 0
}
Runtime journal and Postgres

HTTP 503 triggers backoff

The worker classified the error as transient. It returned the job to the queue with a future retry time.

View captured evidence
{
  "kind": "job_queued",
  "state": "queued",
  "attempt": 1,
  "upstreamStatus": 503,
  "scheduledRetryDelayMs": 3000
}
Test harness

Test upstream restored

The test harness switched the upstream back to normal while the job was waiting.

View captured evidence
{
  "mode": "ok"
}
Runtime journal

Runtime starts attempt two

A worker claimed the job once the persisted retry time had passed.

View captured evidence
{
  "kind": "job_started",
  "state": "running",
  "attempt": 2
}
Runtime journal and upstream observations

Retry succeeds

The second request returned two records and the original job completed.

View captured evidence
{
  "kind": "job_succeeded",
  "state": "succeeded",
  "attempt": 2,
  "upstreamRequests": 2,
  "outcome": "list: 2 items across 1 page(s)"
}

Approval before a connector call

A separate test identity approved a single-page read. The upstream saw zero calls before the decision and one after.

Approval feed

Action waits for approval

The runtime recorded the request and held the action.

View captured evidence
{
  "kind": "requested"
}
Upstream observations

No upstream call yet

The harness checked the upstream request counter before approving.

View captured evidence
{
  "upstreamRequests": 0
}
Approval feed

Separate reviewer approves

A separate test identity allowed the action attached to the approval request.

View captured evidence
{
  "kind": "decided",
  "decision": "allow"
}
Approval feed

Runtime consumes the approval

The runtime consumed the decision for the action that was approved.

View captured evidence
{
  "kind": "consumed"
}
Approval feed and upstream observations

Gated read succeeds

The approval feed links the outcome to the consumed action. The upstream received one read.

View captured evidence
{
  "kind": "outcome_succeeded",
  "upstreamRequests": 1,
  "outcome": "list: 2 items across 1 page(s)"
}