Skip to content

Deleting grains and restarting cluster using AdoNetGrainStorage leads to RecordExists inconsistencies #9697

@shalabala

Description

@shalabala

When using ado storage with SqlServer or PostgreSQL (I assume other providers behave the same way) and deleting a grain that has previously been persisted the IPersistentState.RecordExists property returns false. Once the cluster is shut down and restarted however it once again returns true.

Repro steps:

  • initialize the orleans database with the provided sql scripts link
  • configure ado grain storage with sql server
  • create a grain new and check whether it exists with IPersistentState.RecordExists -> false
  • persist its state for the first time with _persistentState.WriteStateAsync();
  • check whether it exists with IPersistentState.RecordExists -> true
  • delete the grain with _persistentState.ClearStateAsync();
  • check whether it exists with IPersistentState.RecordExists -> false
  • restart cluster
  • check whether it exists with IPersistentState.RecordExists -> true

Versions

I have tried this with 8.0.0 and 9.2.1 (newest at the time of writing this)

Possible workarounds

In the OrleansQuery table if the ClearStorageKey entry is overwritten to fully delete the grain record instead of just setting its state to null the error no longer presents itself

Sample repro project

The database TestProjectOrleans has to be initialized in the SQLEXPRESS for this to work

Output first run:

IN THE BEGINNING: The grain Does not exist
AFTER SAVING: The grain Exists
AFTER DELETING: The grain Does not exist

Output every subsequent run

IN THE BEGINNING: The grain Exists
AFTER SAVING: The grain Exists
AFTER DELETING: The grain Does not exist

ErrorRepro.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions