SqlSugar.SqlSugarException: 中文提示 : 连接数据库过程中发生错误,检查服务器是否正常连接 返回
突然出现大量的这个异常
#SqlSugar.SqlSugarException: 中文提示 : 连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:ORA-50012: Pooled connection request timed outDbType="Oracle";ConfigId="".English Message : Connection open error . ORA-50012: Pooled connection request timed outDbType="Oracle";ConfigId="" at SqlSugar.Check.Exception(Boolean isException, String message, String[] args) at SqlSugar.AdoProvider.CheckConnection() at SqlSugar.OracleProvider.GetCommand(String sql, SugarParameter[] parameters) at SqlSugar.AdoProvider.GetDataReaderAsync(String sql, SugarParameter[] parameters) at SqlSugar.QueryableProvider`1.GetDataAsync[TResult](KeyValuePair`2 sqlObj) at SqlSugar.QueryableProvider`1._ToListAsync[TResult]() at SqlSugar.QueryableProvider`1.CountAsync() at UETokenV2.Service.Message.MessageService.GetUnReadAsync(Reqbase req, CancellationToken cancellationToken) in /src/UETokenV2.Service/Message/MessageService.cs:line 15 at lambda_method44(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.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 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.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)SqlSugar.SqlSugarException: 中文提示 : 连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:ORA-50012: Pooled connection request timed outDbType="Oracle";ConfigId="".
English Message : Connection open error . ORA-50012: Pooled connection request timed outDbType="Oracle";ConfigId="" at SqlSugar.Check.Exception(Boolean isException, String message, String[] args) at SqlSugar.AdoProvider.CheckConnection() at SqlSugar.OracleProvider.GetCommand(String sql, SugarParameter[] parameters) at SqlSugar.AdoProvider.GetDataReaderAsync(String sql, SugarParameter[] parameters) at SqlSugar.QueryableProvider`1.GetDataAsync[TResult](KeyValuePair`2 sqlObj) at SqlSugar.QueryableProvider`1._ToListAsync[TResult]() at SqlSugar.QueryableProvider`1.CountAsync() at UETokenV2.Service.Message.MessageService.GetUnReadAsync(Reqbase req, CancellationToken cancellationToken) in /src/UETokenV2.Service/Message/MessageService.cs:line 15 at lambda_method44(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.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 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.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

热忱回答(14)
-
fate sta VIP0
2025/7/28连接池耗尽:应用程序没有正确关闭连接,导致连接泄漏,连接池达到最大限制。
数据库服务器负载过高,无法及时响应新的连接请求。
网络问题 导致连接建立缓慢或失败。
连接池配置不合理,如
Max Pool Size太小或Connection Timeout太短。
0 回复 -
fate sta VIP0
2025/7/28如果连接池不够引起的错误
那排查并发是不是很高,如果不是很高就会引起连接池异常那就需要
看文档:偶发
0 回复 -
MLT VIP0
2025/7/28我代码之前还行,现在突然就提示这个错误
0 回复 -
fate sta VIP0
2025/7/28上面的排查方向已经给你了
1、线程安全引起的释放失败 (定时任务需要db.CopyNew() 还有Task.WhenAll需要db.CopyNew() ,Void 或者表达式Action中用await是没有等待效果的需要注意)
2、并发过高导致连接池不够
3、网络问题
0 回复 -
会说话的哑巴 VIP0
2025/7/29@fate sta:没有定时任务,WebApi接口流量增加,已经配置 IsAutoCloseConnection = true,不会自动关闭吗?
0 回复 -
会说话的哑巴 VIP0
2025/7/29仓储模式代码,总不能 base.Context = db 要改为 base.Context = db.CopyNew()吧?
/// <summary>
/// 仓储
/// https://www.donet5.com/home/Doc?typeId=1228
/// </summary>
public class Repository<T> : SimpleClient<T> where T : class, new()
{
public Repository()
{
}
/// <summary>
/// 构造函数
/// </summary>
public Repository(ISqlSugarClient db)
{
base.Context = db;
}
}
0 回复 -
会说话的哑巴 VIP0
2025/7/29单例模式 services.AddSingleton<ISqlSugarClient>(sqlSugar);
使用ISqlSugarClient时,需要手动关闭连接吗?
0 回复 -
fate sta VIP0
2025/7/29base.Context = db.CopyNew()吧?
这个是错的
copynew只能当前方法用。不能赋值给变量
0 回复 -
fate sta VIP0
2025/7/29禁止赋值给变量和公用方法
0 回复 -
会说话的哑巴 VIP0
2025/7/30代码中没有使用base.Context = db.CopyNew(),
异常:SqlSugar.SqlSugarException: 中文提示 : 连接数据库过程中发生错误,检查服务器是否正常连接
感觉莫名其妙的,另一项目也出现这个异常,直接改为EFCore正常
SqlSugar号称性能第一,流量增加这个莫名其妙的异常真不知如何解决?
0 回复 -
fate sta VIP0
2025/7/30@会说话的哑巴:
有疑问提供DEMO。 删掉OBJ和BIN打包上传,能重现的
APIPOST工具可以方便的压测
0 回复 -
fate sta VIP0
2025/7/30Oracle新驱动升级了支持了真异步,老版本是假异步 (假异步随便乱写不会有线程问题)
可能你EF是老版本驱动
真异步对线程安全严谨更高
0 回复 -
fate sta VIP0
2025/7/30SqlSugarCore 5.1.4.193 用的是老版本的Oracle驱动,你可退回193测试。
0 回复 -
fate sta VIP0
2025/7/30如果确认是驱动版本差异引起的,那么就按这个改一下异步的代码
0 回复