Unable to Simulate Non-determinism Error

Hello,

I’ve recently started working with Temporal and am trying to understand the concept of non-determinism errors. As per my understanding, if I change my workflow code after a workflow has started, I should face a non-determinism error upon worker restart as the worker would replay the history and compare it with the new code.

I have a long-running workflow with the following code:

func (mw *MyWorkflow) Run(ctx workflow.Context, input MyWorkflowInput) error {
	ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
		StartToCloseTimeout: 2 * time.Second,
		RetryPolicy: &temporal.RetryPolicy{
			InitialInterval:    1,
			BackoffCoefficient: 1,
		},
	})

	var (
		activity1Output Activity1Output
		activity2Output Activity2Output
		activity3Output Activity3Output
	)

	if err := workflow.ExecuteActivity(ctx, mw.Activity.Activity1, &Activity1Input{Input: input.Input}).Get(ctx, &activity1Output); err != nil {
		return err
	}

	if err := workflow.ExecuteActivity(ctx, mw.Activity.Activity2, &Activity2Input{Input: input.Input}).Get(ctx, &activity2Output); err != nil {
		return err
	}

	ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
		StartToCloseTimeout: 2 * time.Second,
		RetryPolicy: &temporal.RetryPolicy{
			InitialInterval:    1,
			BackoffCoefficient: 1,
			MaximumAttempts: 2,
		},
	})

	if err := workflow.ExecuteActivity(ctx, mw.Activity.Activity3, &Activity3Input{Input: input.Input}).Get(ctx, &activity3Output); err != nil {
		return err
	}

	if err := workflow.Sleep(ctx, time.Minute*30); err != nil {
		return err
	}

	return nil
}

I’ve tried to simulate a non-determinism error by doing the following:

  • I changed the order of activities
  • I removed some activities
  • I restarted the worker
  • I restarted the Temporal cluster

Despite these changes, my workflow continues to run successfully without any non-determinism errors. Can someone help me understand why I am not encountering the non-determinism error as expected?

I found a similar question on this forum Replay for non-deterministic change - #3 by antonio.perez and tried the suggested solution, which successfully caused a non-determinism error. However, this hasn’t clarified my understanding of how this mechanism works, nor why it doesn’t check for non-determinism every time

Thank you