Sitelet https://github.com/microsoft/durabletask-dotnet/issues/324
Skip to content

CleanEntityStorageAsync() does not clean entities (likely 'transient' ones) #324

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

EnhancementNew feature or requestP3durable-entitiesRelated to the Durable Entities support milestone

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions