I have noticed that when a terminated workflow is restarted, the workflow gets duplicated. This complicates when I query temporal for all terminated workflows, because it returns the workflow that I have since restarted. How can I differentiate between a terminated workflow and one that was terminated, but since restarted?
Assume we are taking here about the reset feature, let me know if that’s not the case.
when a terminated workflow is restarted, the workflow gets duplicated
If the workflow execution that you are resetting is Running when you issue reset request, the execution is terminated, history is replayed up to the reset point you define and a new workflow execution is created by server with the same workflow id and a different run id. So it’s not a duplicate, its a new execution.
If the workflow execution that you are resetting is already completed (with any completion status) again history is replayed up to your reset point and a new execution with same workflow id and different run id is created.
when I query temporal for all terminated workflows
Can you show how you are querying this please?
How can I differentiate between a terminated workflow and one that was terminated, but since restarted?
They would have different run ids. In addition the workflow execution that was created due to the reset request will have originalExecutionRunId property in the first WorkflowExecutionStarted event in history set to the original exec (one you are resetting) run id.
Hope this helps.