StatckExchange RedisServerException:密钥已从端点移出

时间:2018-11-23 20:43:18

标签: redis stackexchange.redis

批处理HashGetAsync时出现异常


        var redisBatch = redisDb.CreateBatch();
        //track task return, long (the task id), string, the result key, int:0, kline 1,metadata
        var taskTrack = new List>();

        var hashsetRedisKey = RedisKeyBuilder.GetKeyForKLineHashSet(redisResult.hashCode.ToString(), redisResult.klineType);
        var klineTask = redisBatch.HashGetAsync(hashsetRedisKey, redisResult.klineTime.ToString());
        tasks.Add(klineTask);
        taskTrack.Add(Tuple.Create<long, TBKLineRedisQueryTaskResult, int>(klineTask.Id, redisResult, 0));
        var hashsetMetadataRedisKey = RedisKeyBuilder.GetKeyForKLineMetadataHashSet(code.Item1.ToString(), code.Item2);
        var metadataTask = redisBatch.HashGetAsync(hashsetMetadataRedisKey, redisResult.klineTime.ToString());
        tasks.Add(metadataTask);
        taskTrack.Add(Tuple.Create<long, TBKLineRedisQueryTaskResult, int>(metadataTask.Id, redisResult, 1));


    };
    redisBatch.Execute();
    await Task.WhenAll(tasks);

Then I got an exception like below.

StackExchange.Redis.RedisServerException: Key has MOVED from Endpoint 172.31.31.87:6379 and hashslot 9097 but CommandFlags.NoRedirect was specified - redirect not followed for HGET KLineMetadata_K15min_3934036393829150277_HashSet. IOCP: (Busy=1,Free=999,Min=8,Max=1000), WORKER: (Busy=2,Free=32765,Min=8,Max=32767), Local-CPU: n/a at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at TBConnectionLib.Handlers.TBKLineRedisHandler.<GetKLineAndMetadataFromHashsetUsingPipeline>d__20.MoveNext()

我已经在单元测试中尝试过(如果我只把几个键放在Get上)。但是在我的产品中,我将有数百个(而不是数千个)Get密钥,它会向我抛出这种异常。

我的项目是.Net Core,我正在使用SE.Redis 2.0.513

enter image description here

0 个答案:

没有答案