Workflow state

On this page 7

Workflow state is the stored record of where a running workflow instance stands at a given moment: which step it has reached, what data it has collected, which actions have completed or failed and what it is waiting for. In automation, workflow state is what allows a process to pause, resume, retry and be inspected instead of running as a single uninterrupted script.

Every workflow that waits for something, such as an approval, a webhook, a timer or a slow external system, must keep its state somewhere outside memory. How and where that state is stored decides whether the automation survives restarts, scales across workers and produces a trustworthy audit trail.

What workflow state contains

Workflow state combines position, data and history for one workflow instance. The definition of the workflow, its steps, triggers and conditions, stays the same for every run; the state is what differs between runs.

ComponentContentExample
Instance identifierUnique ID of one runOrder approval run for order 48213
Current positionActive step or stepsWaiting at manager approval
StatusLifecycle value of the instanceRunning, waiting, failed, completed
VariablesData gathered or computed so farOrder total, customer tier, approver
Step resultsOutputs and errors of finished actionsCredit check returned approved
Timers and waitsPending deadlines or expected eventsEscalate if no reply in 48 hours
Execution historyOrdered log of transitionsTrigger, check, notify, wait
Components of workflow state

The status field is the part most users see, but recovery depends on the rest. Without stored step results, a restarted workflow cannot know whether an email was already sent or a payment already captured.

How workflow state is stored and advanced

A workflow engine advances state in discrete transitions: it loads the instance, executes the next action, records the result and saves the new state before moving on. Saving after every step, called checkpointing, means a crash loses at most the step in progress.

Engines use two main persistence models. In the snapshot model, the current state is overwritten in a database row or document after each step. In the event-sourcing model, the engine appends every event to a log and reconstructs state by replaying the log, which preserves full history and supports precise debugging at the price of more storage and replay logic.

Long waits are handled by persisting the state and releasing the worker. A workflow waiting three days for an approval consumes a database record, not a running process; when the approval webhook arrives, the engine correlates it with the instance by an identifier and resumes from the saved position.

Stateless and stateful automation compared

Not every automation needs durable workflow state. The choice depends on duration, failure cost and the need for audit.

AspectStateless executionStateful execution
Typical durationSecondsMinutes to months
Waiting for people or eventsNot supportedCore feature
Recovery after crashRerun from the startResume from last checkpoint
Audit trailOnly external logsBuilt-in execution history
InfrastructureFunction or simple scriptWorkflow engine with a database
Best forShort data transformationsApprovals, orders, onboarding
Stateless versus stateful workflow execution

Simple trigger-action automations in low-code tools are often effectively stateless: each run is independent and leaves only an execution log. Once a process contains a wait, a loop over many items or a compensation step, explicit workflow state becomes necessary.

Workflow status values and their meaning

Most engines expose a small set of lifecycle statuses that summarize workflow state for monitoring and alerting. Names vary by platform, but the meanings are broadly consistent.

StatusMeaningTypical next status
PendingCreated, not yet startedRunning
RunningExecuting a stepWaiting, completed or failed
WaitingPaused for a timer, event or personRunning or timed out
FailedStopped by an unhandled errorRunning after retry, or canceled
CompletedReached an end step successfullyNone
CanceledStopped deliberatelyNone
Typical lifecycle statuses

A useful practice is to alert not only on failed instances but also on instances that stay waiting longer than expected, because silently stuck workflows are often more costly than visible failures.

Design rules and common mistakes

Reliable workflow state depends on a few design rules that experienced automation engineers apply consistently. Most production incidents in workflow systems trace back to violating one of them.

  • Make actions idempotent: a step may run twice after a crash, so it must not charge a card or send an invoice twice.
  • Keep state small: store references to large files or records, not the files themselves.
  • Version workflow definitions: running instances must finish on the definition they started with.
  • Avoid hidden state: data held only in a script’s memory or a temporary file is lost on restart.
  • Protect sensitive variables: state often contains personal data and secrets that need encryption and retention limits.
  • Plan for compensation: when a later step fails, earlier completed steps may need explicit undo actions.

Changing a workflow definition while instances are in flight is a frequent source of corruption: a renamed variable or removed step can leave old instances in a state the new definition cannot interpret. Versioning and migration scripts prevent this.

In simple terms

Workflow state is the bookmark and the notes for a process in progress. Imagine a paper form moving between desks for signatures. At any moment, someone could tell you which desk it is on, who has signed and what is still missing. That is its state.

Automated workflows keep the same kind of record in a database. Because of it, a process can wait for days, survive a server restart and continue exactly where it stopped, and anyone can see what happened along the way.

A practical example

A company automates employee onboarding. When HR marks a new hire as signed, a workflow starts and records the start date, department and manager as state variables. It creates accounts, orders a laptop and then waits for the manager to choose software licenses, a step that can take several days.

Midway through one onboarding, the automation server restarts for maintenance. Because the engine saved the state after every step, the instance resumes at the license approval wait instead of creating duplicate accounts. When the manager approves, the workflow continues, and the execution history shows exactly when each account was created and who approved what, which the IT team later uses in an access audit.