OrleansContrib / Orleans.Providers.MongoDB

A MongoDb implementation of the Orleans Providers: Membership, Storage and Reminders.
MIT License
105 stars 44 forks source link

bugfix: using collection name as key for caching collections #131

Closed TimoSchmechel closed 9 months ago

TimoSchmechel commented 9 months ago

Currently the statename is used as the key for caching collections in the MongoGrainStorage. However the statename is always set to "state" as seen here in the Orleans source code: https://github.com/dotnet/orleans/blob/2bcd83351385c0dd98cd3a60cdcfb17ce890f966/src/Orleans.Runtime/Core/GrainRuntime.cs#L88C42-L88C42

This leads to all grain states using the same mongo collection. It will be the first one that gets created with that key which is likely undeterministic depending on your Orleans application.

A simple test scenario can highlight this bug. You just need 2 grain types with their own states. Depending on which grain type is activated first, will determine which mongo collection is used. I can provide a test repo if need be.

This fix just uses the collection name as the key in the cache.

wassim-k commented 9 months ago

Thanks for your contribution, can you please increase the patch version in Orleans.Providers.MongoDB.csproj and we can get it merged.

TimoSchmechel commented 9 months ago

@wassim-k thats done