redis / redis-om-dotnet

Object mapping, and more, for Redis and .NET
MIT License
457 stars 76 forks source link

StackExchange.Redis.RedisServerException after Redis server restart #281

Closed giovanni-ferrari closed 1 year ago

giovanni-ferrari commented 1 year ago

I'm currently running integration tests using "redislabs/redisearch:latest" docker image. The library i'm using to startup the docker container for Redis is TestContainers-dotnet (https://github.com/testcontainers/testcontainers-dotnet)

At the first test execution, inserting an entity and then updating everything works fine. After the Redis' docker container is disposed, and restarted, and the second test in the Theory starts, then the UpdateAsync generates the StackExchange.Redis.RedisServerException, with the following message:

StackExchange.Redis.RedisServerException : NOSCRIPT No matching script. Please use EVAL.

Here below the minimal code to replicate the issue.

public class RedisTests
    {

        [Document(StorageType = StorageType.Json, IndexName = "entity-name", Prefixes = new[] { "TestEntities" })]
        public class TestEntity
        {
            [RedisIdField][Indexed] public string Name { get; set; } = String.Empty;
            [Indexed] public bool IsActive { get; set; }
        }

        [Theory]
        [InlineData("Test1")]
        [InlineData("Test2")]
        public async Task TestRedis(string name)
        {
            const string dockerImage = "redislabs/redisearch:latest";
            const string dockerContainerName = "Redis";
            await using var redis = new TestcontainersBuilder<TestcontainersContainer>()
                                            .WithName(dockerContainerName)
                                            .WithImage(dockerImage)
                                            .WithPortBinding(6379, 6379)
                                            .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(6379))
                                            .Build();
            await redis.StartAsync();
            var redisConnectionProvider = new RedisConnectionProvider($"redis://localhost");
            await redisConnectionProvider.Connection.CreateIndexAsync(typeof(TestEntity));
            var collection = redisConnectionProvider.RedisCollection<TestEntity>();

            var testEntity = new TestEntity
            {
                Name = name,
                IsActive = true,
            };
            await collection.InsertAsync(testEntity);
            testEntity.IsActive = false;
            await collection.UpdateAsync(testEntity);
        }
    }
slorello89 commented 1 year ago

See #272 already Fixed pending release of 0.4.1 ( will go out in the new year as I don't want to push anything out before going on break)

giovanni-ferrari commented 1 year ago

See #272 already Fixed pending release of 0.4.1 ( will go out in the new year as I don't want to push anything out before going on break)

Thanks a lot! Didn't find it with the search, sorry.

giovanni-ferrari commented 1 year ago

See #272 already Fixed pending release of 0.4.1 ( will go out in the new year as I don't want to push anything out before going on break)

Thanks, this is fixed in 0.4.1