dotnet / dotnet/orleans

Errors on Silo start when we have a custom grain directory and a distributed memory one

Open
#8,308 4 comments 0 reactions 1 assignee Claimed by @benjaminpetit View on GitHub
Needs: investigation 🔍
Dominant language
C#
Stars
10.9k
Forks
2.1k
Avg merge
14h 42m
Merged PRs (30d)
354

Description

Hello,

I have an Orleans cluster set up with 2 grain defined, one that uses Redis as a grain directory and another that uses the distributed memory one. For simplicity, I'll call them `RedisGrain` and `DestributedMemoryGrain`.

I manage to have both of these set up on the same cluster by using the `builder.AddRedisGrainDirectory` with a custom name for `RedisGrain` and then I use a `services.AddSingletonNamedService("DestributedMemoryGrain", (_, _) => default!);` for the `DestributedMemoryGrain`. This is to take advantage of the way that [GrainLocatorResolver uses to know which GrainLocator to use](https://github.com/dotnet/orleans/blob/2195a32918ca325090cb01f0cb3eb9c983f49284/src/Orleans.Runtime/GrainDirectory/GrainLocatorResolver.cs#L33), if the requested grain uses the default grain directory then the DhtGrainLocator is used.

When a new silo is created with this configuration the [CachedGrainLocator](https://github.com/dotnet/orleans/blob/2195a32918ca325090cb01f0cb3eb9c983f49284/src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs#L15) is used because of the `RedisGrain` that uses a non-default grain directory. This grain locator, when registering silos uses the `[participate method](https://github.com/dotnet/orleans/blob/2195a32918ca325090cb01f0cb3eb9c983f49284/src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs#L123)` to check if there was any other changes to the configuration of the cluster with the method [ListenToClusterChange](https://github.com/dotnet/orleans/blob/2195a32918ca325090cb01f0cb3eb9c983f49284/src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs#L141). This method does to the list of [all registered grain directories](https://github.com/dotnet/orleans/blob/2195a32918ca325090cb01f0cb3eb9c983f49284/src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs#L160) trying to unregister all existing dead silos.

The issue I'm having is that since the default grain directory is a `null` value, the `directory.UnregisterSilos(deadSilos)` operation produces a null pointer exception. What can I do to prevent this error from being raised?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.