ASPBoilerPlate - 从池中获取连接之前的超时时间

问题描述 投票:0回答:0

我有一个在 AWS ECS linux fargate 上运行的 .net MVC 核心应用程序。有2个案例如下:

  1. MSSQL 数据库托管在与 RDS 相同的 VPC 中:在这种情况下,一切正常。 ECS(容器服务)正在预热,在此期间 ABP 的后台作业也可以正常运行。之后所有应用程序始终无错误地响应。

  2. MSSQL 数据库托管在 EC2 内的不同 VPC 中:问题来了。 ECS 正在预热,正在启动,但在应用程序的日志文件中显示以下错误。应用程序也不会始终以正确的数据响应。我不能说数据库没有连接,因为 ABPAuditLog 表也捕获了这些错误。

错误: WARN 2023-03-24 14:11:44,639 [11] Abp.BackgroundJobs.BackgroundJobManager - System.InvalidOperationException:超时已过期。在从池中获取连接之前超时期限已过。发生这种情况的原因可能是所有池连接都在使用中并且已达到最大池大小。 在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource

1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 重试,DbConnectionOptions userOptions) 在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func
3 操作,Func
3 verifySucceeded) at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.CreateDbContext[TDbContext](String connectionString, IDbContextResolver dbContextResolver) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext](Nullable
1 multiTenancySide,字符串名称) 在 Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase
3.get_Table() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase
3.GetAllIncluding(Expression
1[] propertySelectors) at Castle.Proxies.Invocations.IRepository
2_GetAll_3.InvokeMethodOnTarget() 在 Castle.DynamicProxy.AbstractInvocation.Proceed() 在 Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation 调用,UnitOfWorkOptions 选项) 在 Castle.DynamicProxy.AbstractInvocation.Proceed() 在 Castle.Proxies.IRepository
2Proxy_1.GetAll() at Abp.BackgroundJobs.BackgroundJobStore.GetWaitingJobsAsync(Int32 maxResultCount) at Castle.Proxies.Invocations.BackgroundJobStore_GetWaitingJobsAsync.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.BackgroundJobStoreProxy.GetWaitingJobsAsync(Int32 maxResultCount) at System.Threading.Tasks.Task
1.InnerInvoke() 在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback 回调,对象状态) --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- 在 System.Threading.Tasks.Task.ExecuteWithThreadLocal(任务和 currentTaskSlot) --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- 在 Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task
1 task) at System.Threading.Tasks.ContinuationResultTaskFromResultTask
2.InnerInvoke() 在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback 回调,对象状态) --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- 在 System.Threading.Tasks.Task.ExecuteWithThreadLocal(任务和 currentTaskSlot) --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- 在 Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](任务
1 task) at Nito.AsyncEx.AsyncContext.Run[TResult](Func
1 操作) 在 Abp.BackgroundJobs.BackgroundJobManager.DoWork()

我们尝试增加 dbcontext 超时: a) 在连接字符串中提及超时 b) 在 DbContext

的构造函数中显式设置超时

但没有运气。

aspnetboilerplate
© www.soinside.com 2019 - 2024. All rights reserved.