0

I am using Redis on docker (Centos Linux). it runs properly and works fine for some days or weeks, but sometimes it stops working suddenly. the docker container is up and I can explore its files. But, it does not respond to the redis-cli bash command, GetAsync and SetAsync methods from the StackExchange.Redis package implemented with the IDistributedCache interface or any other commands. I run the Redis container by the following command:

docker run --name x-redis -p 6379:6379 -d redis redis-server --appendonly yes

Here is my docker log file latest info:

{"log":"1:S 19 Feb 2020 04:06:08.957 * Master replied to PING, replication can continue...\n","stream":"stdout","time":"2020-02-19T04:06:08.958110011Z"}
{"log":"1:S 19 Feb 2020 04:06:09.408 * Trying a partial resynchronization (request 1e9525bb8323b08b0d258e78ff5d33107da9c:1).\n","stream":"stdout","time":"2020-02-19T04:06:09.40838749Z"}
{"log":"1:S 19 Feb 2020 04:06:09.633 * Full resync from master: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:0\n","stream":"stdout","time":"2020-02-19T04:06:09.633986888Z"}
{"log":"1:S 19 Feb 2020 04:06:09.633 * Discarding previously cached master state.\n","stream":"stdout","time":"2020-02-19T04:06:09.634015966Z"}
{"log":"1:S 19 Feb 2020 04:06:09.634 * MASTER \u003c-\u003e REPLICA sync: receiving 42680 bytes from master\n","stream":"stdout","time":"2020-02-19T04:06:09.6340791Z"}
{"log":"1:S 19 Feb 2020 04:06:09.860 * MASTER \u003c-\u003e REPLICA sync: Flushing old data\n","stream":"stdout","time":"2020-02-19T04:06:09.860296381Z"}
{"log":"1:S 19 Feb 2020 04:06:09.860 * MASTER \u003c-\u003e REPLICA sync: Loading DB in memory\n","stream":"stdout","time":"2020-02-19T04:06:09.860323416Z"}
{"log":"1:S 19 Feb 2020 04:06:09.860 # Wrong signature trying to load DB from file\n","stream":"stdout","time":"2020-02-19T04:06:09.860350539Z"}
{"log":"1:S 19 Feb 2020 04:06:09.860 # Failed trying to load the MASTER synchronization DB from disk\n","stream":"stdout","time":"2020-02-19T04:06:09.860370074Z"}
{"log":"1:S 19 Feb 2020 04:06:09.860 * Background append only file rewriting started by pid 2838\n","stream":"stdout","time":"2020-02-19T04:06:09.860887072Z"}
{"log":"1:S 19 Feb 2020 04:06:09.884 * AOF rewrite child asks to stop sending diffs.\n","stream":"stdout","time":"2020-02-19T04:06:09.884200771Z"}
{"log":"2838:C 19 Feb 2020 04:06:09.884 * Parent agreed to stop sending diffs. Finalizing AOF...\n","stream":"stdout","time":"2020-02-19T04:06:09.884224364Z"}
{"log":"2838:C 19 Feb 2020 04:06:09.884 * Concatenating 0.00 MB of AOF diff received from parent.\n","stream":"stdout","time":"2020-02-19T04:06:09.884232305Z"}
{"log":"2838:C 19 Feb 2020 04:06:09.884 * SYNC append only file rewrite performed\n","stream":"stdout","time":"2020-02-19T04:06:09.884301823Z"}
{"log":"2838:C 19 Feb 2020 04:06:09.884 * AOF rewrite: 2 MB of memory used by copy-on-write\n","stream":"stdout","time":"2020-02-19T04:06:09.885066707Z"}
{"log":"1:S 19 Feb 2020 04:06:09.908 * Background AOF rewrite terminated with success\n","stream":"stdout","time":"2020-02-19T04:06:09.908571705Z"}
{"log":"1:S 19 Feb 2020 04:06:09.908 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)\n","stream":"stdout","time":"2020-02-19T04:06:09.908593368Z"}
{"log":"1:S 19 Feb 2020 04:06:09.908 * Background AOF rewrite finished successfully\n","stream":"stdout","time":"2020-02-19T04:06:09.908599805Z"}
{"log":"1:S 19 Feb 2020 04:06:10.510 * Connecting to MASTER *IP*:*PORT*\n","stream":"stdout","time":"2020-02-19T04:06:10.510484407Z"}
{"log":"1:S 19 Feb 2020 04:06:10.510 * MASTER \u003c-\u003e REPLICA sync started\n","stream":"stdout","time":"2020-02-19T04:06:10.510506838Z"}
{"log":"1:S 19 Feb 2020 04:06:10.742 * Non blocking connect for SYNC fired the event.\n","stream":"stdout","time":"2020-02-19T04:06:10.742327821Z"}
{"log":"1:S 19 Feb 2020 04:06:11.650 * Module 'system' loaded from /tmp/exp_lin.so\n","stream":"stdout","time":"2020-02-19T04:06:11.650188169Z"}
{"log":"1:M 19 Feb 2020 04:06:11.898 # Setting secondary replication ID to 1e9525bb8323b08b0d258e78ff5d33107da9c, valid up to offset: 1. New replication ID is e3274f106d6fd08e16306c574c12eacda2fca354\n","stream":"stdout","time":"2020-02-19T04:06:11.898549773Z"}
{"log":"1:M 19 Feb 2020 04:06:11.898 * MASTER MODE enabled (user request from 'id=1023 addr=*IP*:*PORT* fd=8 name= age=6 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=34 qbuf-free=32734 obl=0 oll=0 omem=0 events=r cmd=slaveof')\n","stream":"stdout","time":"2020-02-19T04:06:11.89859865Z"}
{"log":"sh: 1: killall: not found\n","stream":"stderr","time":"2020-02-19T04:06:12.722240613Z"}

Configuration in the Startup file:

public void ConfigureServices(IServiceCollection services)
{
    services.AddStackExchangeRedisCache(options =>
    {
        options.InstanceName = "SimpleCache";
        options.Configuration = "IP:PORT"
    });

    services.AddTransient<ICacheService, CacheService>();
    //services.AddSingleton<ICacheService, CacheService>(); ??
}

Implementaion:

public class CacheService : ICacheService
{
    private readonly IDistributedCache _distributedCache;

    public CacheService(IDistributedCache distributedCache)
    {
        _distributedCache = distributedCache;
    }

    public async Task SetAsync(string key, byte[] value)
    {
        //is it ok to use this method without await keyword??
        await _distributedCache.SetAsync(key, value, token);
    }

    public async Task<byte[]> GetAsync(string key)
    {
        var value = await _distributedCache.GetAsync(key);
        return value;
    }
}

I can share any other information if needed.

Pedram
  • 828
  • 9
  • 24
  • Did you check the redis logs for any errors/warnings ? – Zeitounator Feb 23 '20 at 09:40
  • Sorry for the late response @Zeitounator. I can not find Redis log on docker . I've seen [this post](https://stackoverflow.com/questions/16337107/how-to-access-redis-log-file) already, but the path of the log file is empty in the Redis configuration. I just saw the docker log and I'll add it to the question soon. – Pedram Feb 24 '20 at 10:33
  • I already used the `stackexchange.redis` async methods (like `SetAsync` and `GetAsync`) without the `await` keyword (C#). For now, I added that keyword to the code and I have not had this error for some days! could this change be related to that problem?? – Pedram Mar 09 '20 at 07:29

0 Answers0