Temporal workflow versioning and worker deployments

Changing workflow code while executions are running needs a deliberate versioning choice, replay tests against recorded histories, and a worker rollout that drains old code. This page covers how to plan and verify each step.

On this page

How to version Temporal workflow code without breaking running executions

Version Temporal workflow code by treating every running execution as a fixed record of past decisions that new code must still reproduce. A Temporal workflow is rebuilt from its event history through replay, so any change to the order or type of decisions the code makes can break an execution that is already in flight, even when new executions start and finish without trouble. The safe approach combines a versioning or patching method in the workflow code, replay tests against recorded histories before each deploy, and a worker rollout that keeps the old and new code running side by side until nothing depends on the old path.

Teams need this discipline in two situations: any workflow that can outlive a single deploy window, and any change to decision logic such as branching, timers, activity order or child workflow creation, even if the change looks small. A workflow that runs for days or months will be replayed on workers that did not exist when it started, so the question is never only whether new starts work. The harder part is that old executions keep the old logic, workers must run both versions during the overlap, and the old path can only be removed after evidence shows no open execution still needs it. Confirm with your SDK's documentation which versioning mechanisms it provides and how they interact with your deployment tooling, and check that your test suite replays histories captured from production, not only freshly written ones.

Before you ship a change, decide three things in writing: how long the old path must remain in code, who signs off that no open executions still take it, and how you will prove that from workflow listings and histories rather than from memory. Ask any partner or internal owner to show how they query for open executions that carry the old version marker, how they run replay tests in CI against stored histories, and how they roll back a worker deployment if replay fails. Those answers reveal whether the team can retire old code safely, which matters more over a workflow's lifetime than the first release.

Which parts of a Temporal system a code change touches

A Temporal system has several parts that a code change can reach, and each one behaves differently when executions are already running. Knowing which part a change touches tells you whether running workflows, new starts, workers or stored history are affected, and which checks you need before release.

Workflow definitions

A workflow definition is the code that decides what happens next in a business process. Changing its branching, ordering or the activities it calls alters how a running execution continues, because Temporal replays the recorded event history through the new code to rebuild state. A change that reorders or removes commands can make replay fail for executions that started on the old code. Before release, check each change against the event history of running executions and decide whether it needs a patch, a version gate or a new workflow type.

Self-hosted deployment docs

Activities

Activities perform the side-effecting work, such as calling an API, writing to a database or sending a message. Activity results are recorded in event history, but the activity code itself runs again on retry and is not replayed from history. A change to activity logic therefore affects the next attempt of any in-flight activity, not the recorded result of a completed one. Check that changed activities stay idempotent, because a retry can run the new code against work the old code already performed.

Workers that run the code

Workers are the processes that host workflow and activity code and poll task queues for work. A worker deployment is the change most teams see first, because old and new code can run side by side during a rolling release. Each worker must carry the workflow code that matches the histories it may pick up, or replay will fail. Confirm with your SDK documentation how workers advertise their build or version, and plan how many old workers stay online until running executions finish.

Task queues that route work

Task queues hold workflow and activity tasks until a worker polls them. Renaming a queue, splitting it, or moving workers between queues changes where new tasks go, but does not rewrite the history of executions already in progress. Use queue names as a deliberate part of the release plan, for example by routing new starts to a fresh queue while old workers drain the existing one. Confirm how your chosen SDK handles tasks left on a queue that no worker serves.

Event history of each execution

The event history is the durable record of every command, activity result, timer and signal for one execution. It is the input to replay, so it is the reason a code change can break a running workflow. Changes never edit recorded history, but the new code must still reproduce the same decisions when it reads that history. Before you retire an old code path, confirm that no open execution still depends on it, and keep a replay test for representative histories.

Temporal Service or Temporal Cloud namespace

The Temporal Service, whether self-hosted or run as Temporal Cloud, stores event histories and routes tasks within a namespace. Server upgrades are a separate change from workflow code, and they should follow the server upgrade order in the upgrade guidance. Namespace settings, retention and access rules apply to every workflow version in that namespace, so a retention change or a role change affects old and new executions alike. Confirm these settings with the platform owner before a release that also changes workflow code.

Server upgrade guide

Choosing between in-place patching, versioned workflow types and drain-and-replace

This table compares the three main ways to change running Temporal workflow code: in-place patching, running a new workflow type alongside the old one, and draining old executions before replacing code. Read each row against your workflow durations and how much code you are willing to keep. The main takeaway is that the operational cost of each approach falls on code retention, worker capacity and testing, so choose by how long your longest executions run. Exact SDK mechanisms differ by language, so confirm them against the SDK version you run.

ApproachWhen it fitsOperational cost
In-place patching with a version markerSmall, targeted logic changes to long-running workflows that must continue on the same workflow typePatch branches stay in code until no execution can reach them; each new change adds another branch to test and review
New workflow type alongside the old oneLarge behavior changes where old and new logic should not share one code pathBoth types stay deployed until old executions finish; workers must register and poll both, so capacity planning covers the overlap
Drain and replaceShort-lived workflows where waiting for running executions to finish is acceptableRequires knowing the longest execution duration; new starts may pause during cutover and old workers must stay up until drained
Replay testing before rolloutAny change to deterministic workflow code, whichever approach you chooseNeeds recorded or representative histories in CI; a test suite that skips replay can miss nondeterminism that only shows up in production
Retiring old code pathsAfter every execution on a patch or old type has completed or been terminatedNeeds visibility queries or history checks to prove no open executions remain; removing code too early breaks replay
Worker deployment overlapRolling out new worker builds while old ones still serve running executionsOld and new worker versions run at once; confirm the SDK's worker versioning or build ID features before relying on them

How a versioned change moves from build to retirement

The change starts with an inventory of running executions, because that inventory decides which code paths must survive. Each change is then classified as compatible or breaking. A compatible change gets a version guard and replay tests against recorded histories before new workers are deployed beside the old ones. Breaking changes take a different route: new starts are routed to new code while old executions drain. The old code path is removed only when no open executions still depend on it, and that check is the step teams most often skip.

Phases of a Temporal workflow change, with the compatibility and drain decision points.

Build sequence for a safe Temporal workflow version change

This sequence turns a workflow code change into a staged rollout in which running executions finish on the code they started with, and every step ends with a check that the team can record before moving on.

  1. Confirm the server runs a supported version

    Before any workflow change, the platform owner confirms that the Temporal Server runs a supported minor version at its latest patch, with schema changes applied where the release notes call for them. Versioning rules assume a healthy, current server, so an out-of-date cluster is fixed first. Server upgrades are planned separately, and Helm chart and server compatibility are covered on the Kubernetes deployment page. Done when the team has written confirmation of the running server version and the upgrade history is documented.

  2. List open executions by workflow type and age

    The platform owner runs visibility queries to list every open execution grouped by workflow type, version marker and start time. This shows which code paths running executions still depend on and how old the oldest ones are. Visibility must be working for these queries to be reliable, so the team confirms the advanced visibility store responds before relying on the results. Done when the team has a saved inventory that states the count of open executions per workflow type and the age of the oldest one.

  3. Classify the change and choose the approach

    The workflow owner and a senior engineer decide whether the change is compatible with running executions. A change that only adds a new branch can often use a patch or version guard, while a change to the sequence of commands in an existing path usually needs a new workflow type. The classification also records which activities, timers and signal handlers are affected. Done when the change is labeled with its approach in the change record and reviewed by a second engineer.

  4. Add the version guard or new workflow type

    The developer writes the change behind a version guard so that executions started before the change follow the old path, or registers a new workflow type and leaves the old one in place. The guard or new type is kept small so it is easy to read and remove later. The developer records each guard identifier in the change record. Done when the code compiles, unit tests cover both branches, and the guard identifiers appear in the change record.

  5. Capture real event histories

    The team exports event histories for representative open executions from production or from a staging copy that matches production workflow activity. Histories should cover each old path that the change touches, including long-running executions that already passed the guard point. Sensitive payloads are handled under the team's data handling rules, and the team confirms that payload decoding for the export is permitted. Done when a fixture set exists for every affected workflow type and the set is stored with the change.

  6. Run replay tests in CI against captured histories

    Replay tests run in continuous integration against the captured histories using the new worker code. A replay failure means the new code would make a different decision than the original run, which would corrupt running executions. Any non-determinism error blocks the merge until the guard, the ordering of commands or the history fixture is corrected. Done when the replay test passes on every captured history and the CI result is linked from the change record.

  7. Deploy workers that serve both versions

    The worker owner deploys the new worker build alongside the old one, or as a single build that contains both code paths, so that any worker can resume either kind of execution. Each worker pool is checked for the registered workflow and activity types before it receives tasks. Done when every worker pool reports the expected registrations and no task queue is left without a worker that understands the old path.

  8. Shift new starts and monitor the drain

    Once both versions run, the team routes new workflow starts to the new path and watches the open execution inventory fall as old executions finish. The team checks for failed tasks, non-determinism errors and stuck timers during the drain. Done when a visibility query shows zero open executions on the old path and the old workers are removed from the task queues, with the result recorded before the old code is deleted.

How worker rollout differs for self-hosted and Temporal Cloud

With a self-hosted Temporal Service, your team runs the server services, the persistence store and any visibility store, and also the worker fleet. Workers usually run as ordinary application deployments in the same cloud account or cluster, or in a separate worker network that can reach the Temporal frontend. Your platform or application team owns the rollout pipeline, so the blue-green, canary or rolling strategy, the health checks and the rollback path are yours to design and test. Old and new worker pools can coexist on the same task queue, but only if the new code is compatible with executions already started, which makes versioning and replay testing part of the release gate.

  • Worker location: Workers run in your Kubernetes cluster or on hosts you manage, connected to the frontend over internal networks.
  • Pipeline ownership: Your CI/CD tooling and release approvers control when each worker version is deployed and drained.
  • Pool coexistence: Old and new pools can run side by side during a rollout, and you decide how long the old pool stays up.
  • Server upgrades: Server and Helm chart versions must match the Temporal documentation for the release you run, so confirm chart compatibility before changing worker images.
  • Network exposure: Keep Temporal services off the public internet and restrict access to trusted internal networks.

Confirm the server, chart and SDK versions against the upgrade and deployment documentation for your chosen release before you plan the rollout.

What drives the effort of versioning and worker rollout

This table lists the factors that make changing running Temporal workflows harder, why each one adds work, and how teams keep it contained. Read each row as a question to answer about your own estate before you estimate the versioning and rollout work, since several drivers multiply each other.

DriverWhy it raises effortHow to keep it down
Workflow types in flightEach workflow type with running executions needs its own compatibility decision, patch marker or version branch, and its own replay check before deployment.Group related workflows under stable entry points, retire types that have no running executions, and review the in-flight list before each release.
Average execution durationLong-running executions can stay open across many deployments, so old code paths must keep working for longer and more versions must coexist.Break very long processes into child workflows or shorter stages where the design allows, and record which version each stage was started under.
Maximum execution durationThe oldest running execution sets how long compatibility code must stay in the codebase, which is often far longer than teams expect.Confirm the longest expected run with process owners, set workflow timeouts deliberately, and schedule cleanup of patch code only after the oldest execution has completed.
SDK languages and worker servicesEach language SDK and each worker service has its own build, release and rollout path, so a change must be coordinated across all of them.Standardize on as few SDK languages as the business allows, and deploy workers that share a task queue with a single release train where possible.
Frequency of changesFrequent changes multiply the number of versions in flight at once and the number of replay checks to run for each release.Batch related workflow changes, automate replay tests in the build pipeline, and agree a release cadence with the teams that own the workflows.
Size and variety of captured historiesReplay tests need recorded histories that cover the branches a change touches, and large or varied histories take longer to store, select and replay.Capture representative histories from each workflow type and version, keep a curated test set, and refresh it as new branches are added.
Multi-namespace setupsEach namespace has its own workflows, workers and versions, so compatibility checks, worker deployments and access settings repeat per namespace.Use a consistent naming and deployment pattern across namespaces and script the checks so the same process runs in each one.
Compliance evidence requirementsAssessors may ask for records of which code version ran which workflow, proof that replay tests ran before each release, and approval trails for retirement of old versions.Ask assessors early which records they expect, store replay results and deployment approvals automatically, and keep version history in source control.

How to test that a change is safe before and after rollout

Replay testing is the main pre-release check for a workflow code change. Before any new worker build receives traffic, run the new workflow code against recorded histories from executions that started on the old code, and confirm each history replays without nondeterminism errors. Choose the histories deliberately. Include the oldest open executions, because they have passed through the most former code paths. Include executions that are paused at a timer or waiting on a signal, since those are where a changed command order is most likely to surface. Add histories from failed or retried executions, which exercise error branches that happy-path samples miss. Any branch guarded by a version marker needs at least one history from each side of the guard. Confirm in your own test harness how your SDK exports histories and how it reports nondeterminism, because the failure mode and error text differ by language and SDK version.

A canary period shows what replay cannot. Replay only proves that existing histories still make the same decisions, not that new executions behave correctly under production load. Run the new build on a small worker pool that is allowed to pick up new task queue traffic, and watch workflow task failures, activity error rates, retry counts and workflow durations against the baseline from the old pool. Keep the canary pool pinned to the same task queue so it competes with the old workers under identical conditions. During drain, watch for old-version executions that stop progressing, because they now depend entirely on old workers. Track the count of open executions per workflow type and version, and confirm that count falls as expected before you remove any old workers.

Fail safely by keeping old workers until drain completes. Do not scale down the previous worker deployment until no open executions still need its code. Define the rollback path in advance: shift new task starts back to the old build and leave running executions where they are, rather than terminating or restarting them. This works only if the old code is still deployed, its version markers and patches are still present, and its SDK remains compatible with the server. Write down who can trigger rollback, what signals end the canary, and how long the old pool stays available. Confirm with your platform team how your deployment tooling keeps both builds running at the same time, since that behavior depends on your own environment.

Access and secrets that rollout pipelines must respect

A rollout touches the Temporal Service, the workers and the data inside running workflows, so each path needs its own access and secrets controls before a change ships. The cards below cover the defaults to override first, the identities that may act during a change, and the data that leaves production when histories are copied for testing.

Override the default noopAuthorizer

Self-hosted Temporal allows every API request until an Authorizer is configured. Without one, any client that can reach the frontend can start, signal or terminate workflows, including during a deployment. Before any rollout pipeline runs, confirm that an Authorizer is active in every environment and that the pipeline does not depend on the default behavior. Test this in staging by attempting a restricted call with an unscoped credential and checking that it is refused.

Security docs

Encrypt internode and frontend traffic

Mutual TLS can separate internode traffic between Temporal services from frontend traffic that clients and workers use. Pipelines that deploy new worker versions open connections to the frontend, so certificate issuance, rotation and trust settings for worker hosts belong in the rollout plan. Ask your platform team which certificate authority signs each side, how long certificates last, and how a failed rotation would appear during a deployment window.

Map claims to namespace roles

A ClaimMapper translates JWT or certificate claims into namespace roles, which lets you separate who may deploy workers from who may start, signal or terminate workflows. During a version change, limit termination rights to a small on-call group and keep deployment identities out of that group. Review the mapping before the change window, since a broad claim mapping can grant termination rights to a pipeline that only needed to restart workers.

Scope worker and pipeline secrets

Workers that call payment, messaging or data systems hold credentials for those systems, and a new worker version may need different ones. Store these secrets in your existing secret manager, issue each worker version its own scoped identity where the external system supports it, and revoke the old identity once the last execution on that version has finished. Confirm with each external system owner how rotation affects workers that are still replaying history.

Redact payloads before copying histories

Event histories record workflow inputs, activity results and signal data, which often contain personal or financial information. Replaying production histories against a new code version is a standard test, but copies moved into test environments should pass through a custom codec and encryption first, or be stripped of payloads. Agree with your compliance team who may access decrypted histories and where the codec keys are held, since test environments are often less controlled than production.

Keep services off the public internet

Temporal services should run on hosts that the public internet cannot reach, with access limited to trusted internal networks. Rollout pipelines, worker fleets and the frontend should sit inside private subnets, and any CI runner that needs to reach the cluster should connect through a controlled network path. Ask your network team to confirm this for every environment, including the staging cluster used for replay tests.

Deployment docs

What to monitor, keep and document after each version change

After a workflow code change reaches production, the first thing to watch is the open execution count for each workflow type and version. Old executions keep running on the code path they started with until they finish, so the count for the old version should fall over time, not stall. Track it per workflow type and per version guard, and alert when a version has open executions but no recent progress. Also watch worker task failures and nondeterminism errors in worker logs, since a replay mismatch usually shows up there first. Queue backlogs during the overlap period deserve their own dashboard, because workers that serve both the old and new paths can be slower than either version alone. Record the date each old code path last ran in production, because that date is the evidence you need before deleting the branch.

Keep the material that lets you prove a change is safe later. Store captured workflow histories from production or representative runs, because they are the inputs to replay tests and let you re-check a new build against real executions before it ships. Keep the replay test suite in the same repository as the workflow code and run it in continuous integration for every change. Keep a version decision record for each change that states what was altered, why the patch or new version was chosen, and which worker builds were expected to run it. These records are what an auditor or a new engineer will ask for when a long-running workflow behaves unexpectedly months later.

For each version guard, document its purpose, the retirement criteria and a named owner. Retirement criteria should be concrete, such as no open executions on the old version for a stated period and a clean replay of retained histories against the code without the guard, and the owner should be the team that can approve removing the branch. Confirm with your own engineering leads what period and evidence they will accept, since the right answer depends on your longest-running workflows and retention settings. Server and SDK upgrades are covered in the upgrades topic and are not treated in depth here, but the version decision records should note which SDK and server versions each guard was written against so that later upgrades can be checked against them.

Questions teams ask before changing Temporal workflows in production

Can our own team change Temporal workflows in production without outside help?

Yes, many teams can, provided they already write workflows against the Temporal SDK and have someone who understands determinism, which is the property that lets Temporal replay a workflow's history after a restart. The work needs engineers who can read event histories, run replay tests in CI, and coordinate worker rollouts with operations staff. Outside help usually matters most when the team has never changed a running workflow, when many long-lived executions span several code generations, or when the change touches several services at once. Before deciding, ask who owns the workflow code, who can answer questions about in-flight executions at night, and whether the team has rehearsed a rollback.

How long does a workflow versioning change take, and what sets that duration?

The duration depends mostly on how many workflow types and running executions are affected, how long those executions live, and how much replay testing already exists. Workflows that run for days or months keep old code paths alive for longer, so the retirement phase often takes more calendar time than the code change itself. Other drivers include the number of workers and worker pools, whether the team uses a deployment strategy that keeps old and new code running together, the maturity of the CI pipeline, and the approval steps for production changes. No duration is given here because it varies with the environment, so ask a prospective partner to break the estimate into inventory, code change, replay testing, rollout and retirement.

What would a partner scope and quote for a versioning engagement?

A written scope usually starts with an inventory of workflow types, their longest-running executions, the SDK and server versions in use, and the places where workflow code is shared with activities or other services. It then covers the chosen change approach, replay test coverage, the worker deployment plan, the retirement criteria for each old path, and the handover of runbooks. Quotes follow from that scope, so ask for each item to be listed separately, with what is one-time (inventory, design, test harness, runbooks) and what recurs (on-call support, upgrades, continuous testing). DeployOpen does not publish a price list; a quote follows from the written scope.

Can an existing workflow be changed safely while executions are running?

A change can be made safely only when the new code produces the same command sequence as the recorded history for every execution that is still running, or when the old sequence is explicitly preserved behind a version check. Adding, removing or reordering timers, activities, child workflows or signal handling without a versioning marker can cause a non-determinism error during replay. Safety therefore depends on the change type, the executions in flight, and whether replay tests run the real histories against the new build before rollout. Teams should test changes against recorded histories from production-like workloads, not only against new test runs.

What should we confirm about the SDK and server versions we run?

Confirm the Temporal SDK language and version used by every worker, the server version, and the Helm chart version if the cluster runs on Kubernetes. Check the server release notes for compatibility guidance before any upgrade, because Temporal guarantees backward compatibility between successive minor versions, and schema upgrades must run before server upgrades when the notes call for them. Also confirm that the versioning feature you plan to use is supported by your SDK and server combination, and that all workers in a task queue run builds that can replay the same histories. Record these pairings in the change plan so that a rollback targets a known-good combination.

How do we decide when it is safe to retire an old workflow code path?

Retire an old path only when no open execution can still reach it and no replay test needs its history. The practical check is to confirm, from the visibility store, that no running workflows carry the old version marker, and that the longest retention period for closed executions has also passed if those histories must still be replayed for audits or debugging. Retirement should follow a deployment in which the new code has been stable for a defined period, with a documented rollback path until the old path is removed. Ask the team to write these criteria down per workflow type, since a long-running process may keep an old branch alive far longer than a short one.

How DeployOpen scopes, builds and hands over Temporal versioning work

DeployOpen treats Temporal workflow versioning and worker deployments as a fixed-scope piece of work agreed in writing before changes start. We inventory the running workflow types, build the versioning and replay tests against your own code, and hand over runbooks your team can repeat for future releases.

How we scope

  • We list the workflow types, activities and worker fleets that will change, and which executions are still running.
  • The written scope names the versioning approach for each change, the replay test suite and the deployment strategy.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing; ongoing support is available as a retainer.

How we build

  • We add patching or versioning markers to workflow code and confirm them with replay tests against recorded histories.
  • We set up worker deployment, drain and rollback steps for the environments you run, including your own cloud or data center.
  • We verify that old versions stay registered until their last open executions finish, then document the retirement steps.

How we hand over

  • You receive the workflow change log, versioning decisions, replay test code and the deployment runbook.
  • We walk your engineers through a release, with a dry run of rollback and retirement, so the process runs without us.
  • Each change is recorded with the Temporal version and SDK version it was tested against, for future reviews.

How we support

  • Retainers cover reviews of new workflow changes, replay test maintenance and worker deployment support.
  • Support can include upgrades to newer Temporal Server and SDK releases, scoped and tested in your environment.
  • Ongoing testing and checks follow the same written scope, so changes to support work are agreed before they start.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.