2

I have an orchestration that runs as a singleton by using the same instance id each time. It also runs infinitely by using ContinueAsNew at the end of each iteration to keep the history manageable. However, I have noticed that the history of each past iteration is kept in the history table, each with a different execution id (as is expected when ContinueAsNew is called).

I also use PurgeInstanceHistoryAsync once a day to delete any completed, failed, terminated or cancelled orchestrations that are more than 14 days old. However, since the infinite singleton orchestration is never in any of these states will PurgeInstanceHistoryAsync ever clean up the old execution histories?

The same question can be asked for a periodic singleton orchestration (i.e. an orchestration that runs periodically but uses the same instance Id each time). If the purge process happens whilst the orchestration is running, will any old histories be removed, or would it be a matter of luck that the orchestration is not actually running at the time the purge executes?

Boschy
  • 126
  • 10

1 Answers1

0

If you look in your history table in the azure storage account and query for your instance you should see that using ContinueAsNew will actually purge history automatically. (In my test it seemed to be at most 1 execution behind.)

From Docs: https://learn.microsoft.com/sv-se/azure/azure-functions/durable/durable-functions-eternal-orchestrations?tabs=csharp#resetting-and-restarting

When ContinueAsNew is called, the instance enqueues a message to itself before it exits. The message restarts the instance with the new input value. The same instance ID is kept, but the orchestrator function's history is effectively truncated.

Bjorne
  • 1,424
  • 7
  • 13
  • I have read that piece before and while I agree that's probably what it means, it doesn't specifically say that the old audit history is deleted. It only says "effectively truncated". "Effectively" in this case could well mean that a search by the new execution id only returns the current history, not all past histories. The reason I asked is because I currently have 10 distinct execution id's in my history for the one instance id. What I don't know is if some of them are left over from past failed instances that were restarted by a fail-safe timer trigger, of if they just weren't deleted. – Boschy Mar 03 '21 at 21:19