Skip to content

Retry Engine Specification

Document ID: WF-008 Version: 1.0.0 Status: Draft Owner: Workflow Engine Team Last Updated: 2026-06-26


This document defines the Retry Engine used by the Wovyr Workflow Engine.

The Retry Engine is responsible for recovering from transient failures while maintaining deterministic workflow execution.

It provides:

  • Configurable retry policies
  • Exponential backoff
  • Linear retry
  • Fixed interval retry
  • Jitter support
  • Circuit breaker integration
  • Retry budgeting
  • Dead-letter handling
  • Failure classification

The Retry Engine operates independently from the Scheduler and Activity Workers.


The Retry Engine must provide:

  • Deterministic retries
  • Configurable retry policies
  • High reliability
  • Fault tolerance
  • Replay compatibility
  • Retry observability
  • Resource protection

The Retry Engine follows these principles:

  1. Retry only transient failures.
  2. Permanent failures must not be retried.
  3. Retry decisions are deterministic.
  4. Every retry attempt is persisted.
  5. Retry history is immutable.
  6. Retries must survive worker failures.
  7. Retry policies are versioned.

Activity Failure
Failure Classifier
┌────────────┴────────────┐
▼ ▼
Permanent Failure Retry Eligible
│ │
▼ ▼
Workflow Failure Retry Planner
Backoff Calculator
Scheduler Delay Queue
Activity Worker

Running
Failure
Retry Evaluation
┌──┴─────────────┐
▼ ▼
Retry Permanent Failure
Delayed
Scheduled
Running

Global example:

retry:
enabled: true
maxAttempts: 5
strategy: exponential
initialDelay: 2s
maxDelay: 2m
multiplier: 2.0
jitter: true

Activities may override the global policy.


Supported strategies:

5s
5s
5s
5s

5s
10s
15s
20s

2s
4s
8s
16s
32s

2.1s
3.8s
8.6s
15.4s
31.2s

Recommended for distributed deployments.


Failures are categorized before retry.

TypeRetry
Network timeoutYes
Temporary database outageYes
Rate limitingYes
HTTP 429Yes
HTTP 503Yes
Worker crashYes
Invalid inputNo
Validation failureNo
Permission deniedNo
Schema errorNo

Custom classifiers may be registered.


Each workflow maintains a retry budget.

Example:

retryBudget:
maxAttempts: 100
maxDuration: 2h

When exhausted:

  • Retries stop.
  • Workflow failure policy is invoked.

The runtime stores:

retry:
attempts:
lastAttempt:
nextAttempt:
strategy:
delay:
reason:

Retry state is checkpointed.


Retryable activities enter the Delay Queue.

Failure
Delay Queue
Scheduler
Worker

The Delay Queue is durable and survives restarts.


Retry scheduling considers:

  • Retry delay
  • Queue priority
  • Worker availability
  • Tenant limits
  • Rate limits

Retry scheduling is deterministic.


When maximum attempts are reached:

Attempt 1
Attempt 2
Attempt 3
Attempt 4
Attempt 5
Failure Policy

No further retries occur.


Retry policies interact with:

  • Activity timeout
  • Workflow timeout
  • Lease timeout

Retries never extend workflow timeout unless explicitly configured.


Circuit breakers prevent repeated failures.

States:

Closed
Open
Half Open
Closed

While open, retries are skipped.


Activities exceeding retry limits may be moved to a Dead Letter Queue.

Stored information:

  • Workflow ID
  • Activity ID
  • Failure reason
  • Retry history
  • Stack trace
  • Metadata

Operators may inspect or replay failed activities.


Retry metadata is persisted after:

  • Every failure
  • Every retry
  • Delay calculation
  • Retry completion
  • Retry exhaustion

Persistence guarantees recovery.


Replay restores:

  • Retry count
  • Delay state
  • Failure history
  • Pending retry

Replay never duplicates completed retries.


If a worker crashes during retry:

  1. Lease expires.
  2. Retry state restored.
  3. Scheduler requeues activity.
  4. Retry continues.

No retry attempts are lost.


Expose:

  • Retry attempts
  • Retry success rate
  • Retry failure rate
  • Retry latency
  • Retry queue size
  • Average retry delay
  • Retry budget usage

Every retry event logs:

workflowId:
executionId:
activityId:
attempt:
strategy:
delay:
failureReason:
workerId:
timestamp:

Retry operations enforce:

  • Tenant isolation
  • Worker authorization
  • Immutable audit logs
  • Secure persistence
  • Replay validation

pub trait RetryStrategy {
fn next_delay(
&self,
attempt: u32,
) -> Duration;
fn should_retry(
&self,
error: &WorkflowError,
) -> bool;
}

engine-workflow/
└── retry/
├── engine.rs
├── strategy.rs
├── classifier.rs
├── delay_queue.rs
├── budget.rs
├── circuit_breaker.rs
├── dead_letter.rs
├── persistence.rs
├── metrics.rs
└── mod.rs

  • Retry calculation
  • Strategy selection
  • Failure classification
  • Budget enforcement
  • Scheduler integration
  • Checkpoint recovery
  • Delay queue persistence
  • Circuit breaker behavior
  • Millions of retries
  • Large delay queues
  • High concurrency
  • Distributed scheduling
  • Worker failure
  • Database outage
  • Queue corruption
  • Network partition

RequirementTarget
Retry calculation< 1 ms
Delay queue lookup< 5 ms
Retry persistence< 10 ms
Replay correctness100%
Duplicate retries0
Recovery correctness100%

  • Workflow Overview
  • Execution Model
  • Scheduler
  • State Machine
  • Checkpointing
  • Compensation
  • Persistence
  • Distributed Execution
  • Event Bus
  • Rust Crate Design

VersionDateDescription
1.0.02026-06-26Initial Retry Engine Specification