Skip to content
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

阿里云主从redis出现链接超时,但是监控显示一切正常 #197

Open
QianYS opened this issue Aug 2, 2024 · 5 comments
Open

Comments

@QianYS
Copy link

QianYS commented Aug 2, 2024

错误所示:
2024-07-31 21:23:42.156 +08:00 [ERR] Connection id "0HN57R8AORGCD", Request id "0HN57R8AORGCD:00000001": An unhandled exception was thrown by the application.
System.Exception: 【xsusercenter.redis.rds.aliyuncs.com/18】Status unavailable, waiting for recovery. Connect to redis-server(xsusercenter.redis.rds.aliyuncs.com:6379 -> Unspecified/xsusercenter.redis.rds.aliyuncs.com:6379) timeout, DEBUG: Dns.GetHostEntry(xsusercenter.redis.rds.aliyuncs.com)=System.Net.IPHostEntry
---> System.TimeoutException: Connect to redis-server(xsusercenter.redis.rds.aliyuncs.com:6379 -> Unspecified/xsusercenter.redis.rds.aliyuncs.com:6379) timeout, DEBUG: Dns.GetHostEntry(xsusercenter.redis.rds.aliyuncs.com)=System.Net.IPHostEntry
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) --- End of inner exception stack trace --- 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.PoolingAdapter.<>c__DisplayClass10_01.<<AdapterCallAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at FreeRedis.RedisClient.LogCallAsync[T](CommandPacket cmd, Func1 func)
at InternalApi.Controller.PhoneController.GetRedis(String redisConnStr, String num) in /app/InternalApi/Controller/PhoneController.cs:line 41
at InternalApi.Controller.PhoneController.QueryPhone(String phone) in /app/InternalApi/Controller/PhoneController.cs:line 74
at lambda_method24(Closure, Object)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 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() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)

发生异常时的阿里云监控均是正常
image
image
image
亦未找到慢读取情况

问题发生时间大约是7月31日21点-21点40,问题发生后短时间无法解决,故将redis读取调整为读取数据库
具体api代码如图
image

是否能有更具体的相关信息提现是因为什么而导致的连接超时,或者出现问题时应该如何去定位这个问题的根本原因

@2881099
Copy link
Owner

2881099 commented Aug 2, 2024

怎么不用单例啊?

@MoondanceZ
Copy link

我也出现这种情况, 一般都是在站点发布之后出现, 很奇怪

@2881099
Copy link
Owner

2881099 commented Aug 8, 2024

确保不是被redis防火墙拒绝,min pool size设置为1,避免预热导致防火墙错误判断为攻击而拒绝。

请确保网络环境通畅,健康。

@MoondanceZ
Copy link

min pool size 和 max pool size 怎么理解呢

@kiyeer
Copy link

kiyeer commented Oct 22, 2024

我的也阿里云Redis,出现跟楼主一样的情况,我使用的单例注入。每次暂停站点,更新文件后重新开启,都会出现链接超时的问题,然后刷新1,2次就好了。不知道为什么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants