I have a workflow that has the following activities and logic
a <- ActivityA()
if some_condition (a)
ActivityB()
else
ActivityC()
I’m going to modify that to
x <- ActivityX()
if some_condition (x)
ActivityB()
else
ActivityC()
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?
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
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.