Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ilia-Kosenkov opened this issue Jun 6, 2024 · 0 comments
Labels
durable-entities Related to the Durable Entities support milestone Enhancement New feature or request P3

Comments

@Ilia-Kosenkov
Copy link

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.

@lilyjma lilyjma added durable-entities Related to the Durable Entities support milestone Enhancement New feature or request labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
durable-entities Related to the Durable Entities support milestone Enhancement New feature or request P3
Projects
None yet
Development

No branches or pull requests

3 participants