I’m having some trouble understanding why I am receiving workflow panics for non-determinism and hoping someone can help. Here is the situation:
The existing code executes a workflow with three activities (A, B, C)
I wanted to make a change to add a workflow sleep in activity A. To do that, I used this code:
vers := workflow.GetVersion(ctx, "sleep1", workflow.DefaultVersion, 1)
if vers != workflow.DefaultVersion {
if errSleep := workflow.Sleep(ctx, 2*time.Second); errSleep != nil {
logger.Errorf("unable to sleep workflow: %w", errSleep)
}
}
This works fine for new workflows.
But what I am seeing is that for existing running workflows that are in a retry state on activity C, I am getting the workflow panic for non-deterministic behavior.
I looked at the docs and it does say that a change in sleep duration can cause this.
So my question is - how can activity C cause a panic when the code to do the sleep is in Activity A and not even executed since the workflow is in Activity C? Also, the code is properly wrapped with versioning (I think) so there should not be a panic. Hoping someone knows the answer as we need to use versioning more going forward. Thank you.