Skip to content

PurgeInstanceAsync() not removing taskhub history table entries #3191

@LorryGailius

Description

@LorryGailius

We are using durable functions in an isolated process with only one orchestration calling further sub-orchestrations. We have setup a timer to remove the orhcestration execution and it's history

[Function(Name)]
public async Task Run(
    [TimerTrigger("0 0 0 * * 0", RunOnStartup = false)] TimerInfo myTimer,
    [DurableClient] DurableTaskClient durableTaskClient)
{
    logger.LogInformation("Starting orchestration history purge.");

    var instances = await durableTaskClient
        .GetAllInstancesAsync(new()
        {
            CreatedFrom = new DateTime(2000,1,1,0,0,0),
            CreatedTo = DateTime.UtcNow.AddDays(-7),
            Statuses =
            [
                OrchestrationRuntimeStatus.Completed,
                OrchestrationRuntimeStatus.Failed,
                OrchestrationRuntimeStatus.Terminated
            ]
        })
        .ToListAsync();

    var purgeTasks = instances
        .Select(instance =>
            durableTaskClient.PurgeInstanceAsync(
                instance.InstanceId,
                new PurgeInstanceOptions(Recursive: true)));

    await Task.WhenAll(purgeTasks);
}

The problem is, it deletes the instance from blob storage, so it is not accessible through GetAllInstancesAsync() anymore, but none of the entries in the {taskHub}History table are deleted

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions