As outlined in the Workflow Implementation Constraints section, Workflow code has to be deterministic by taking the same code path when replaying history events. Any Workflow code change that affects the order in which decisions are generated breaks this assumption. The solution that allows updating code of already running Workflows is to keep both the old and new code. When replaying, use the code version that the events were generated with and when executing a new code path, always take the new code.
Workflow.getVersion function to return a version of the code that should be executed and then use the returned
value to pick a correct branch. Let's look at an example.
Now we decide to calculate the processed file checksum and pass it to upload. The correct way to implement this change is:
Later, when all Workflows that use the old version are completed, the old branch can be removed.
The Id that is passed to the
getVersion call identifies the change. Each change is expected to have its own Id. But if
a change spawns multiple places in the Workflow code and the new code should be either executed in all of them or
in none of them, then they have to share the Id.