Workflow Versioning + Changes to workflow itself

Hey all,

I have a workflow that has the following activities and logic

a <- ActivityA()
if some_condition (a)

I’m going to modify that to

x <- ActivityX()
if some_condition (x)

In summary I’m going to replace Activity A with X and the whole workflow will be updated to use the response of X instead of A.

My question is, when versioning workflow, should I add version checks for every place where we use the response of A or X OR just at the place where we call ActivityA or ActivityX?

Hi @Sayuru

You have to add a version check to every place.

Briefly explained, every time your code makes an activity invocation, the workflow API creates a command that ends up being an event stored in the Workflow Execution’s Event History. The event contains both the execution and the result, along with other information.

When the workflow is re-executed, instead of calling the activity again, the workflow API looks for the event (in the event history) and retrieves the result and continues executing the logic.

So, if some_condition (a) != some_condition (x) your code is gonna take a different path, what will cause a non-deterministic error

You can read about it here What is a Workflow Definition? | Temporal Documentation

This video might be of your interest as well Temporal Java SDK Workshop Part 2: Client APIs, Sleep, Versioning, Error Handling, Dynamic Workflows - YouTube

You can use ReplayWorkflowHistoryFromJSONFile to test your modified code. Here is an example: samples-go/replay_test.go at main · temporalio/samples-go · GitHub

Just to add, you can change your activity code without breaking working determinism. For your example you can change the code for activity A and as long as it retains the same return type should work without having to use versioning.
Just note that if you do that and have running executions that are retrying on activity A when you update activity code and restart your workers, the updated code will be applied on the next retry for these executions.

Thank you all for all your responses. I think I now correctly understand how workflow versioning will work and what needs to be done. Thanks bunches!!