microsoft / microsoft/durabletask-dotnet

`CleanEntityStorageAsync()` does not clean entities (likely 'transient' ones)

Open
#324 0 comments 1 reaction 2 assignees View on GitHub

@YunchuWang is already working on this.

Since Dec 24, 2025.

durable-entities Enhancement P3
Dominant language
C#
Stars
193
Forks
60
Avg merge
3d 12h
Merged PRs (30d)
4

Description

Hi! I am migrating some code from from in-process durable framework to isolated model, and I got stuck with handling entities.
I was looking for an option to completely delete entities. Reading docs, I learned that I can use DurableTaskClient.CleanEntityStorageAsync() to clean storage. I manually delete state for entities I wish to query and then I call this method, which does nothing, reporting that it purged exactly 0 entities.
Now my entities in question appear to be 'transient' so that I need to pass new EntityQuery { IncludeTransient = true } to GetAllEntitiesAsync() in order to see them in the output. It feels like by deleting state I promoted entities to transient and now entity storage is not cleaned because of that. The scenario for debugging is roughly the following:


// Here I get two transient entities with no state
var entities = await client.Entities
  .GetAllEntitiesAsync(
      new EntityQuery
      {
          IncludeState = true,
          IncludeTransient = true
      }
  )
  .ToListAsync();

// And here I get 0 removed entities and 0 orphaned locks released
var result = await client.Entities.CleanEntityStorageAsync(
    new CleanEntityStorageRequest
    {
        RemoveEmptyEntities = true,
        ReleaseOrphanedLocks = true
    }
  );

// Here again I get two entities
var entitiesAfter = await client.Entities
  .GetAllEntitiesAsync(
      new EntityQuery
      {
          IncludeState = true,
          IncludeTransient = true
      }
  )
  .ToListAsync();

Perhaps I do not understand something about this flow?

Also, when querying for entities, even though I specify IncludeState = true, resulting metadata do not include state and have IncludesState set to false. Is this how it is supposed to work?

I debug this code locally, backing durable framework by Azurite storage, so I can access and inspect my entities, and check if they are removed or not, or if they have associated state.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.