csredis icon indicating copy to clipboard operation
csredis copied to clipboard

哨兵 Master 重新选举后出现 Connection was not opened

Open beckjin opened this issue 10 months ago • 3 comments

csreids 错误【172.21.96.2:6379/0】:Connection was not opened at CSRedis.Internal.IO.RedisIO.GetOrThrow[T](T obj) at CSRedis.Internal.IO.RedisIO.get_Stream() at CSRedis.Internal.IO.RedisIO.Write(Byte[] data) at CSRedis.Internal.RedisConnector.Call[T](RedisCommand1 command) at CSRedis.RedisClient.Write[T](RedisCommand1 command) at CSRedis.RedisClient.HGet(String key, String field) at CSRedis.CSRedisClient.<>c__DisplayClass207_0.<HGet>b__0(Object1 c, String k) at CSRedis.CSRedisClient.<>c__DisplayClass53_01.<ExecuteScalar>b__0(Object1 conn) at CSRedis.CSRedisClient.GetAndExecute[T](RedisClientPool pool, Func2 handler, Int32 jump, Int32 errtimes)

System.Exception: Redis Sentinel Master is switching:Connection was not opened at CSRedis.CSRedisClient.GetAndExecute[T](RedisClientPool pool, Func2 handler, Int32 jump, Int32 errtimes) at CSRedis.CSRedisClient.ExecuteScalar[T](String key, Func3 hander) at CSRedis.CSRedisClient.Exists(String key)

beckjin avatar Apr 15 '24 08:04 beckjin

可以尝试 FreeRedis

2881099 avatar Apr 15 '24 12:04 2881099

【172.21.96.3:26379/0】Status unavailable, waiting for recovery. Connection refused at FreeRedis.Internal.ObjectPool.ObjectPool1.GetFree(Boolean checkAvailable) at FreeRedis.Internal.ObjectPool.ObjectPool1.Get(Nullable1 timeout) at FreeRedis.RedisClient.PoolingAdapter.GetRedisSocket(CommandPacket cmd) at FreeRedis.RedisClient.PubSub.Subscribe(Boolean psub, Boolean ssub, String[] channels, Action3 handler) at FreeRedis.RedisClient.Subscribe(String channel, Action2 handler) at FreeRedis.RedisClient.SentinelAdapter..ctor(RedisClient topOwner, ConnectionStringBuilder sentinelConnectionString, String[] sentinels, Boolean rw_splitting) at FreeRedis.RedisClient..ctor(ConnectionStringBuilder sentinelConnectionString, String[] sentinels, Boolean rw_splitting) at MD.Redis.Free.FreeRedisHelper.CreateFreeRedisClient(RedisOptions options) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()n--- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()n--- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) Connection refusedr at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)n--- End of stack trace from previous location --- at System.Threading.Tasks.TaskToApm.End(IAsyncResult asyncResult) at FreeRedis.Internal.DefaultRedisSocket.Connect() at FreeRedis.Internal.DefaultRedisSocket.Write(CommandPacket cmd) at FreeRedis.RedisClient.SingleInsideAdapter.<>c__DisplayClass5_01.<AdapterCall>b__0() at FreeRedis.RedisClient.LogCallCtrl[T](CommandPacket cmd, Func1 func, Boolean aopBefore, Boolean aopAfter) at FreeRedis.RedisClient.LogCall[T](CommandPacket cmd, Func1 func) at FreeRedis.RedisClient.SingleInsideAdapter.AdapterCall[TValue](CommandPacket cmd, Func2 parse) at FreeRedis.RedisClient.Call(CommandPacket cmd) at FreeRedis.Internal.RedisClientPoolPolicy.PrevReheatConnectionPool(ObjectPool1 pool, Int32 minPoolSize)"}

FreeRedis 情况类似。我们模拟的情况是直接把某个实例所在的服务器关掉。

beckjin avatar Apr 30 '24 05:04 beckjin

情况基本与 https://github.com/2881099/FreeRedis/issues/180 一致

beckjin avatar May 01 '24 07:05 beckjin