Net5 WebApi项目 使用Oracle.ManageDataAccess.Core 版本号3.21.110
“oracle”:”data source=192.168.1.1/his;password=12345;user id=app;Pooling = true;Max Pool Size = 200;Min Pool Size = 10;Connection Timeout=200;Validate connection=true”,
但是报错提示: racle.ManagedDataAccess.Client.OracleException (0x80004005): Pooled connection request timed out at OracleInternal.ConnectionPool.PoolManager3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OracleConnectionDispenser3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria) at Oracle.ManagedDataAccess.Client.OracleConnection.Open() at HS.GS.MI.Platfom.Api.Startup.b__4_2(IServiceProvider x) at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope ) at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope ) at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope ) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired) at lambda_method985(Closure , IServiceProvider , Object[] ) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.g__CreateController|0(ControllerContext controllerContext) 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.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() — End of stack trace from previous location — at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 121 at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at HS.MI.Platform.Api.MiddleWares.ApiHeadeAuthentiactionMiddlware.InvokeAsync(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at HS.MI.Platfom.Api.MiddleWares.CustomExceptionMiddleware.InvokeAsync(HttpContext context)
3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OracleConnectionDispenser
有没有超级大神帮忙看一下是什么原因,有些服务器合适的,就2个服务器偶尔会出状况,提示这个超时了
根据你提供的错误信息,”Pooled connection request timed out” 提示是由于数据库连接池中的连接已被耗尽,新的连接请求超时。这种情况通常发生在以下几种情况下:
以下是一些可能的解决方案:
检查并优化连接池配置:
Max Pool Size
Min Pool Size
10
csharp "oracle":"data source=192.168.1.1/his;password=12345;user id=app;Pooling=true;Max Pool Size=500;Min Pool Size=20;Connection Timeout=200;Validate connection=true",
检查并确保连接正确释放:
using
csharp using (OracleConnection conn = new OracleConnection(connectionString)) { conn.Open(); // 执行数据库操作 } // using 语句会确保在代码块结束时自动关闭连接
检查数据库服务器性能:
检查网络稳定性:
日志与监控:
确保在数据库操作中正确释放连接,以下是一个示例:
public void ExecuteDatabaseOperation() { string connectionString = "data source=192.168.1.1/his;password=12345;user id=app;Pooling=true;Max Pool Size=500;Min Pool Size=20;Connection Timeout=200;Validate connection=true"; using (OracleConnection conn = new OracleConnection(connectionString)) { conn.Open(); // 执行数据库操作 using (OracleCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM your_table"; using (OracleDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { // 处理查询结果 } } } } // using 语句确保连接被正确关闭 }
通过上述步骤和建议,希望能够解决你遇到的 Oracle 数据库连接超时问题。如果问题仍然存在,建议与 Oracle 数据库管理员(DBA)合作,深入分析数据库服务器的运行状况和负载。