bugfix: using collection name as key for caching collections #131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.