Orleans.Redis icon indicating copy to clipboard operation
Orleans.Redis copied to clipboard

GrainReference not deleted from redis

Open ElectNewt opened this issue 3 years ago • 1 comments

Hi, I am working to implement Orleans sagas in our system and I find that the GrainReference does not get removed from redis once the saga is completed.

This is my configuration:

.UseOrleans((ctx, orleansBuilder) =>
            {
                orleansBuilder
                    .UseSagas(typeof(TSagaAssembly).Assembly)
                    .ConfigureServices(services => services.Scan(scan => scan
                        .FromAssemblyOf<TSagaAssembly>()
                        .AddClasses()
                        .AsSelfWithInterfaces()
                    ))
                    .UseRedisReminderService(opt => opt.ConnectionString = redisAddress)
                    .AddRedisGrainStorageAsDefault(options =>
                    {
                        options.ConnectionString = redisAddress;
                        options.DeleteOnClear = true; //<- here I assume this will do it.
                        
                    })
                    .UseRedisClustering(options =>
                    {
                        options.ConnectionString = redisAddress;
                    });

                orleansBuilder.Configure<EndpointOptions>(options =>
                {
                    // Port to use for Silo-to-Silo
                    options.SiloPort = 11111;
                    // Port to use for the gateway
                    options.GatewayPort = 30000;
                    // IP Address to advertise in the cluster
                    options.AdvertisedIPAddress = IPAddress.Parse("127.0.0.1"); //TODO: it should be host ip
                    // The socket used for silo-to-silo will bind to this endpoint
                    options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, 40000);
                    // The socket used by the gateway will bind to this endpoint
                    options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, 50000);
                });
                orleansBuilder.Configure<ClusterOptions>(options =>
                {
                    options.ServiceId = $"{redisGrainStorageName}-service";
                    options.ClusterId = $"{redisGrainStorageName}-cluster";
                });
            })

I assumed that DeleteOnClear will clear up the record but seems like it doesn't. As I am still able to see it in Redis.

Also, I am using the version 3.1.1 (i need it to be compatible with netcore3.1);

there is no error or anything additional, is there any way to remove it? Thanks.

edit: updated the version to the correct one.

ElectNewt avatar Dec 06 '21 17:12 ElectNewt

Hello,

First of all - I noticed that RedisStorageOptions.DeleteOnClear is not used at all and seems never be used (BTW @ReubenBond - is it OK? what was the initial goal of such setting?). So does not matter what value RedisStorageOptions.DeleteOnClear has. Grain state will be deleted from Redis only when Grain.ClearStateAsync() is called (Redis DEL command will be executed).

I have no experience with Orleans.Sagas. But what can I say - I've cloned their repo, checked out master branch (as of now, it points to https://github.com/OrleansContrib/Orleans.Sagas/commit/ba13ae41cecfdd074b163e01ae040f96446ebf99), opened solution file, and simple text search of 'ClearState' within entire solution brings no results. It seems that Orleans.Sagas just does not clean state of its grains (SagaGrain, SagaCancellationGrain) when saga completes.

f-i-x-7 avatar Jan 14 '22 19:01 f-i-x-7