Hi
The Java sdk section on workflow id reuse policy doesn’t mention “terminate if running” at all, and the section in the encyclopaedia is misleading
This policy allows for only one Workflow Execution with a specific Workflow Id to be running at any given time.
This makes it sound like temporal offers a guarantee that the old workflow will stop before the new workflow starts - which would be quite useful for serialising access to objects to eliminate the possibility of race conditions. However in my experience when a workflow is terminated, it’s in-flight activities may continue running at the same time as the new workflow. There’s no guarantee which workflow’s activities will complete first, and it’s quite possible they will interfere with each other. Given that activities are where side effects occur, to me, this means the two workflows are running at the same time.
I’m not really sure what the purpose of this feature is and I think ideally it would wait for the activities to complete before starting the new workflow, however at the least the docs should be corrected
I’m fairly sure I read in the temporal docs that this feature could be used to serialise access to entities, but I can’t find it now. If it did exist, that place should be updated too