首页 > 解决方案 > PurgeInstanceHistoryAsync 是否删除使用 ContinueAsNew 的无限编排的旧历史记录

问题描述

我有一个编排,它每次都使用相同的实例 ID 作为单例运行。它还通过在每次迭代结束时使用 ContinueAsNew 无限运行以保持历史可管理。但是,我注意到每次过去迭代的历史都保存在历史表中,每个都有不同的执行 ID(正如调用 ContinueAsNew 时所预期的那样)。

我还每天使用一次 PurgeInstanceHistoryAsync 来删除任何超过 14 天的已完成、失败、终止或取消的业务流程。但是,由于无限单例编排永远不会处于这些状态中的任何一个,PurgeInstanceHistoryAsync 是否会清理旧的执行历史记录?

可以针对周期性单例编排(即定期运行但每次使用相同实例 ID 的编排)提出相同的问题。如果清除过程在编排运行时发生,是否会删除任何旧的历史记录,或者在清除执行时编排实际上没有运行是否是幸运的问题?

标签: azure-durable-functions

解决方案


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://docs.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.


推荐阅读