orleans icon indicating copy to clipboard operation
orleans copied to clipboard

StateStorageBridge ClearStateAsync does not reset the State property anymore

Open tomhreb opened this issue 5 months ago • 3 comments

Hello,

we've upgraded from 8.1 to 8.2.1 and found out following change in behavior caused by PR #9417.

ClearStateAsync from StateStorageBridge class does not reset the state to default value anymore. It is not clear to me whether this is wanted, according to the description in mentioned PR.

IGrainState<T>.State should never be null after returning from an IGrainStorage method without an exception being thrown. That means it should be set to a new instance of T in ReadStateAsync() and ClearStateAsync() before returning if it would otherwise have been null.

Is this a bug or wanted behavior?

In any case, the current behavior is not consistent with MemoryStorage, where the state is still set to default value _activatorProvider.GetActivator<T>().Create().

Thank you Tomas

tomhreb avatar Jul 23 '25 08:07 tomhreb

Hi, any comments on this?

tomhreb avatar Oct 27 '25 11:10 tomhreb

Hi @tomhreb, when you say ClearStateAsync does not set the state to default, what does it do. Does it leave the state unchanged?

ReubenBond avatar Oct 27 '25 15:10 ReubenBond

Hi @ReubenBond yes - exactly. Stays unchanged, which was changed here: https://github.com/dotnet/orleans/pull/9417/files#diff-65b32be6328ceb2cfe9eb987c313bc3cd7eb2424b65c6aed1e0deb65036f1100L127

tomhreb avatar Oct 31 '25 09:10 tomhreb