abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.99k stars 3.46k forks source link

An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call #20993

Open diennttlu opened 1 month ago

diennttlu commented 1 month ago

When multiple requests are sent to the system at the same time,

There are 2 exceptions I received from the system The fisrt: Message: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call. Stack trace: System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call. at async Task Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync<TState, TResult>(TState state, Func<DbContext, TState, CancellationToken, Task> operation, Func<DbContext, TState, CancellationToken, Task<ExecutionResult>> verifySucceeded, CancellationToken cancellationToken) at async Task Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken) x 2 at async Task Volo.Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken) at async Task Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository<TDbContext, TEntity>.DeleteManyAsync(IEnumerable entities, bool autoSave, CancellationToken cancellationToken) at async Task Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at async Task Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at async Task Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at async Task Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func<IInvocation, IInvocationProceedInfo, Task> proceed) at async ValueTask Volo.Abp.OpenIddict.Tokens.AbpOpenIddictTokenStore.PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken) at async Task Volo.Abp.OpenIddict.Tokens.TokenCleanupService.CleanAsync() ---> Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. at async Task Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at async Task Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) x 3 at async Task Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList entriesToSave, CancellationToken cancellationToken) x 2 at async Task Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync<TState, TResult>(TState state, Func<DbContext, TState, CancellationToken, Task> operation, Func<DbContext, TState, CancellationToken, Task<ExecutionResult>> verifySucceeded, CancellationToken cancellationToken) ---> Microsoft.Data.SqlClient.SqlException: Transaction (Process ID 1637) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. at Task Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)+(Task result) => { } at void System.Threading.Tasks.ContinuationResultTaskFromResultTask<TAntecedentResult, TResult>.InnerInvoke() at async Task Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) x 2 at async Task Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) --- End of inner exception stack trace ---

The seconds: Message: Failed executing DbCommand ("4,569"ms) [Parameters=["@p4='?' (DbType = Guid), @p0='?' (Size = 40), @p5='?' (Size = 40), @p1='?' (DbType = DateTime2), @p2='?' (DbType = Boolean), @p3='?' (DbType = DateTime2), @p10='?' (DbType = Guid), @p6='?' (Size = 40), @p11='?' (Size = 40), @p7='?' (DbType = DateTime2), @p8='?' (DbType = Boolean), @p9='?' (DbType = DateTime2), @p16='?' (DbType = Guid), @p12='?' (Size = 40), @p17='?' (Size = 40), @p13='?' (DbType = DateTime2), @p14='?' (DbType = Boolean), @p15='?' (DbType = DateTime2), @p22='?' (DbType = Guid), @p18='?' (Size = 40), @p23='?' (Size = 40), @p19='?' (DbType = DateTime2), @p20='?' (DbType = Boolean), @p21='?' (DbType = DateTime2), @p28='?' (DbType = Guid), @p24='?' (Size = 40), @p29='?' (Size = 40), @p25='?' (DbType = DateTime2), @p26='?' (DbType = Boolean), @p27='?' (DbType = DateTime2), @p34='?' (DbType = Guid), @p30='?' (Size = 40), @p35='?' (Size = 40), @p31='?' (DbType = DateTime2), @p32='?' (DbType = Boolean), @p33='?' (DbType = DateTime2)"], CommandType='Text', CommandTimeout='30']" ""SET NOCOUNT ON; UPDATE [OpenIddictTokens] SET [ConcurrencyStamp] = @p0, [DeletionTime] = @p1, [IsDeleted] = @p2, [LastModificationTime] = @p3 WHERE [Id] = @p4 AND [ConcurrencyStamp] = @p5; SELECT @@ROWCOUNT;

UPDATE [OpenIddictTokens] SET [ConcurrencyStamp] = @p6, [DeletionTime] = @p7, [IsDeleted] = @p8, [LastModificationTime] = @p9 WHERE [Id] = @p10 AND [ConcurrencyStamp] = @p11; SELECT @@ROWCOUNT;

UPDATE [OpenIddictTokens] SET [ConcurrencyStamp] = @p12, [DeletionTime] = @p13, [IsDeleted] = @p14, [LastModificationTime] = @p15 WHERE [Id] = @p16 AND [ConcurrencyStamp] = @p17; SELECT @@ROWCOUNT;

UPDATE [OpenIddictTokens] SET [ConcurrencyStamp] = @p18, [DeletionTime] = @p19, [IsDeleted] = @p20, [LastModificationTime] = @p21 WHERE [Id] = @p22 AND [ConcurrencyStamp] = @p23; SELECT @@ROWCOUNT;

UPDATE [OpenIddictTokens] SET [ConcurrencyStamp] = @p24, [DeletionTime] = @p25, [IsDeleted] = @p26, [LastModificationTime] = @p27 WHERE [Id] = @p28 AND [ConcurrencyStamp] = @p29; SELECT @@ROWCOUNT;

UPDATE [OpenIddictTokens] SET [ConcurrencyStamp] = @p30, [DeletionTime] = @p31, [IsDeleted] = @p32, [LastModificationTime] = @p33 WHERE [Id] = @p34 AND [ConcurrencyStamp] = @p35; SELECT @@ROWCOUNT;"

ABP 6.0.0 EF Core UI Angular

maliming commented 1 month ago

hi

BenStevenson-FreshRF commented 1 month ago

We've just noticed these issues pop up also - on v8.3.2

SELECT count(*)::int
FROM "SBCLogs" AS s
WHERE s."TenantId" IS NULL
2024-10-21 21:52:50.944 +00:00 [ERR] An exception occurred while iterating over the results of a query for context type 'TVD_Holdings_Ltd.SBC.EntityFrameworkCore.SBCDbContext'.
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
 ---> Npgsql.NpgsqlException (0x80004005): Exception while reading from stream
 ---> System.TimeoutException: Timeout during reading attempt
   at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
SELECT a."TenantId", a."Id", a."UserName"
FROM "AbpUsers" AS a
WHERE NOT (a."IsDeleted")
2024-10-21 21:52:50.960 +00:00 [ERR] An exception occurred while iterating over the results of a query for context type 'TVD_Holdings_Ltd.SBC.EntityFrameworkCore.SBCDbContext'.
Npgsql.PostgresException (0x80004005): 25P02: current transaction is aborted, commands ignored until end of transaction block
   at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
  Exception data:
    Severity: ERROR
    SqlState: 25P02
    MessageText: current transaction is aborted, commands ignored until end of transaction block
    File: postgres.c
    Line: 1498
    Routine: exec_parse_message