Being able to start workflow even though AllowDuplicateFailedOnly is used

Hello experts.

I have a workflow that is started using WorkflowIDReusePolicy as WorkflowIDReusePolicyAllowDuplicateFailedOnly.
I have a domain, that was created using RetentionInDays as 3.

I have started this workflow and everything works great. After the workflow completes, if i try to start it again it fails with the following error: WorkflowExecutionAlreadyStartedError. Ok until now, right?
But i noticed that, after the three days have passed if i try to start the same workflow it starts normally. It wont fail by WorkflowExecutionAlreadyStartedError.

Is this behavior expected? :thinking_face: If so and i don’t want to allow this behavior, should i manage this state by myself?

In my perspective, it should with fail by WorkflowExecutionAlreadyStartedError even though the retention period has passed.

This is by design. After a workflow is closed the workflow uniqueness is guaranteed up to the retention period. After the retention, all the information about the workflow is deleted from the system.

If you need long term deduplication the current approach would be either not closing workflow or keeping ids in a separate datastore.

Thank you so much @maxim!