dotnet/orleans

Error from storage provider AdoNetGrainStorage during ReadStateAsync with primitive types

Opened this issue · 1 comments

If you has a primivite type as peristent state (IPersistentState<bool>) and write state, then clear stete. ReadState will throw exception:

Exc level 0: System.NullReferenceException: Object reference not set to an instance of an object.
   at Orleans.Storage.AdoNetGrainStorage.ReadStateAsync[T](String grainType, GrainId grainReference, IGrainState`1 grainState) in /_/src/AdoNet/Orleans.Persistence.AdoNet/Storage/Provider/AdoNetGrainStorage.cs:line 275
   at Orleans.Core.StateStorageBridge`1.ReadStateAsync() in /_/src/Orleans.Runtime/Storage/StateStorageBridge.cs:line 85

Seams to be relatet to #7780 and #6580

Steps to Repro:

  1. Configure ADO Grain Storage
  2. Activate a grain with a unique ID and a IPersistentState
  3. call IPersistentState.WriteStateAsync()
  4. call IPersistentState.ClearStateAsync()
  5. call IPersistentState.ReadStateAsync() or
  6. wait for grain deactivation
  7. activate grain with same unique ID

This is common to happend when a ClearState is called and the grain gets deactivated. When a grain i activitate again this error will happend due to a call to ReadState on grain being activated.

Expected Behavior:

Shoud be able to use ReadState after ClearState (as it is in grain activation),
or make it realy clear that primivite types as persistent state is not supported with ADOnet storage provider.

This issue also appears to be related to #9165.