-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
连接池整个不可用是否恰当? #199
Comments
并发高连接池不够用的时候,触发的 链接池Timeout 不会导致整个链接池不可用。 并发时归还不及时导致 链接池Timeout,可能是IO问题(网络或硬盘),解决办法可以设置更大的连接池数量,或者从根本解决io问题。 提醒:连接超时,连接池超时,是两个概念。 |
你们修改后的包在哪里下载 |
StackExchange.Redis 有这个问题吗 |
新的包怎么引用,我们有出现dns 解析失败。然后大面积超时 |
{"Success":false,"Message":"【redis.time.com:6399/0】Status unavailable, waiting for recovery. Connect to redis-server(redis.time.com:6399-> Unspecifiedredis.time.com:6399) timeout, DEBUG: Dns.GetHostEntry(redis.time.com)=System.Net.IPHostEntry"} |
我们也出现这种情况 请问新包怎么引用? @xiaolipro |
一直也没有回我。 |
解决了吗?今天下午又一次崩溃了。。 |
1 异常堆栈
😭 轨迹中台测试环境异常_Error
cap-msg-id:316993851092066309
System.Exception: 【redis-test.default.svc.cluster.local:6379/6】Status unavailable, waiting for recovery. Connect to redis-server(redis-test.default.svc.cluster.local:6379 -> Unspecified/redis-test.default.svc.cluster.local:6379) timeout, DEBUG: Dns.GetHostEntry(redis-test.default.svc.cluster.local)=System.Net.IPHostEntry
---> System.TimeoutException: Connect to redis-server(redis-test.default.svc.cluster.local:6379 -> Unspecified/redis-test.default.svc.cluster.local:6379) timeout, DEBUG: Dns.GetHostEntry(redis-test.default.svc.cluster.local)=System.Net.IPHostEntry
at FreeRedis.Internal.DefaultRedisSocket.Connect()
at FreeRedis.Internal.DefaultRedisSocket.Write(CommandPacket cmd)
at FreeRedis.RedisClient.SingleInsideAdapter.<>c__DisplayClass5_0`1.b__0()
at FreeRedis.RedisClient.LogCallCtrl[T](CommandPacket cmd, Func`1 func, Boolean aopBefore, Boolean aopAfter)
at FreeRedis.RedisClient.LogCall[T](CommandPacket cmd, Func`1 func)
at FreeRedis.RedisClient.SingleInsideAdapter.AdapterCall[TValue](CommandPacket cmd, Func`2 parse)
at FreeRedis.RedisClient.Call(CommandPacket cmd)
at FreeRedis.Internal.RedisClientPoolPolicy.PrevReheatConnectionPool(ObjectPool`1 pool, Int32 minPoolSize)
--- End of inner exception stack trace ---
at FreeRedis.Internal.ObjectPool.ObjectPool`1.GetFree(Boolean checkAvailable)
at FreeRedis.Internal.ObjectPool.ObjectPool
1.Get(Nullable
1 timeout)at FreeRedis.RedisClient.PoolingAdapter.GetRedisSocket(CommandPacket cmd)
at FreeRedis.RedisClient.PoolingAdapter.<>c__DisplayClass10_0`1.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at FreeRedis.RedisClient.LogCallAsync[T](CommandPacket cmd, Func`1 func)
at SJZY.Track.Application.Services.TrackPush.TrackPushCacheService.GetPushContentConfigsAsync(Int32 subSystemId, Int32 customId) in /var/lib/jenkins/workspace/trackapi-test/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs:line 24
at SJZY.Track.Application.EventHandlers.TrackPushEventHandler.ConsumerAsync(TrackPushEvent event) in /var/lib/jenkins/workspace/trackapi-test/src/SJZY.Track.Application/EventHandlers/TrackPushEventHandler.cs:line 43
at lambda_method987(Closure, Object)
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at DotNetCore.CAP.Internal.SubscribeInvoker.ExecuteWithParameterAsync(ObjectMethodExecutor executor, Object class, Object[] parameter)
at DotNetCore.CAP.Internal.SubscribeInvoker.InvokeAsync(ConsumerContext context, CancellationToken cancellationToken)
2 猜测
2.1 连接池问题
2.2 网络问题
3 问题分析
此问题和业务代码木有直接关系,业务代码只是简单访问redis。
从异常来看是网络问题,找了运维看几次也没看出问题,所以只能分析freeredis源码了。
2.1 定位异常
直接定位到freedis核心方法Get,这是我们取得redis client的方法
可以看见,正是因为满足UnavailableException != null,才出现了我们看见的
我们找到赋值UnavailableException 的地方:将对象池设置为不可用,后续 Get/GetAsync 均会报错,同时启动后台定时检查服务恢复可用
反推引用,会发现回到了innert exception的stack底部 AdapterCall
2.2 排除连接池
通过上面的定位已经可以排除连接池嫌疑了,因为get rdc的点只有一个:GetRedisSocket。
感兴趣的自己去具体了解一下,这里稍微介绍一下free redis连接池设计:任何redis操作都要从ObjectPool Get一个rdc(RedisClient)出来
而池子的容量是有限的(MaxPoolSize控制),如果在某个时间内有大量的redis访问,可能导致池满
何时归还:
2.2 重现errormessage
排除连接池嫌疑后,目光可以回到引发异常的两行代码了
不管是写还是读,内部实现都调用了Connect方法
至此我们已经还原了所有异常堆栈、message。
4 解决方案
修改free redis源码,我们暂时维护了自己的版本,后续可能会pr到free redis。
5 总结
The text was updated successfully, but these errors were encountered: