New RunId in Replaying a workflow

I want to understand following scenarios in replay:

  1. when will existing workflow be replayed keeping runId intact?
  2. when will existing workflow be terminated and new workflow with new runId will be created?
  1. when will existing workflow be replayed keeping runId intact?

Every time the workflow state needs to be reconstructed the replay is used. Note that this is invisible to the workflow code. So you should program like replay is not happening assuming that the workflow code is deterministic.

  1. when will existing workflow be terminated and new workflow with new runId will be created?
  • When a workflow completes and a new workflow with the same WorkflowId is started.
  • When a workflow is terminated by an explicit terminate command and a new workflow is started.
  • When a workflow is reset to some point in its past the new runId is used