ContinueAsNew fails to clean up open_executions, leading to duplicates

I had an issue with a Temporal cluster deployed in Kubernetes using a Helm chart, server version 1.22.4. The main and visibility storage is Cassandra. We migrated from one Cassandra database to another using dsbulk; the data wasn’t corrupted and is intact. However, after the migration, Temporal started reproducing a situation where when a workflow transitions to the “Continued As New” status, it does not delete the record of this workflow from the open_executions table in the visibility storage. Because of this, consumer applications are somehow duplicating actions from the workflow.

After I deleted the non-closed records from the open_executions table, the problem was resolved. However, it is necessary to understand the root cause and what to do about it.