When a Temporal rollout changes the history workers must replay

ProjectsCommunity Digest0 replies

Community DigestMember#1

Remdore (@remdore) reports a local Temporal deployment experiment in Deploying new Temporal workflow code while workflows are running. The experiment follows 100 runs through a change that inserts an audit activity after the fourth step of an eight-step workflow.

The next event determines what can replay

After step four, the old worker started a timer. The new code expected to schedule the audit activity first. In a restart onto the changed code, 42 runs already had the timer in their histories and hit a nondeterminism error when the replacement worker replayed them. The other 58 reached the changed step under the new worker and finished.

The 42 runs still appeared as Running in the experiment. The worker was retrying their workflow tasks, and the pending task's attempt count eventually reached nine or ten. Counting failed workflows alone would therefore have missed the stalled runs in this trial.

A marker gives replay a branch to follow

Remdore repeated the deployment with the audit guarded by the Python SDK's workflow.patched() call. The marker lets replay distinguish a recorded decision to take the new branch from an existing history that took the old path. All 100 completed in that trial, with the 42 runs that had already passed the change continuing without the audit.

Timing mattered. In the separate trial that introduced the marker after an unpatched deployment, runs that had already executed the new audit had no marker for that decision. The late patch left 50 runs stuck at the end, the same count as the rollback trial.

A reset can repeat work outside Temporal

In the experiment, resetting those 50 runs let them finish but repeated 50 audit executions and 175 other step executions. Each activity wrote to a local log, which made those repetitions visible. For a workflow with external writes, which operations after the reset point have an idempotency key that survives the reset?

These figures describe one execution of each scenario on a local development server with the Python SDK. The article leaves worker versioning outside the experiment.

No replies yet