Base solution for your next web application

Activities of "hongbing.wang"

Product version: 11.2.1 Product type: Angular Product framework type: .net core

This issue may be related to ABP framework. ABP framework version: 7.2

In our project, we can delete a single entity, which contains many children and grandchildren, without any issues. 1.

private async Task DeleteControllerDevicesAsync(int controllerId)
            {
                  // delete credentials
                  await credentialRepository.DeleteAsync(d => d.ControllerId == controllerId);
 
                  // delete user access rights
                  await cagRepository.DeleteAsync(d => d.ControllerId == controllerId);
 
                  // delelet timezone and holiday mapping
                  await tzLinkRepository.DeleteAsync(d => d.ControllerId == controllerId);
 
                  await deviceRepository.DeleteAsync(d => d.ParentId == controllerId);
            }
//delete the entity
await _deviceRepository.DeleteAsync(id);

However, if we delete 4 or more of the same entities at the same time from our Angular client, we got the following exception.

at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(CancellationToken cancellationToken) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.SaveChangesAsync(CancellationToken cancellationToken) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesAsync() at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.CompleteUowAsync()

2022-10-03 17:56:35.674 ERR] An exception occurred in the database while saving changes for context type 'umsplus.EntityFrameworkCore.umsplusDbContext'. 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. ---> Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Transaction (Process ID 72) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

2022-10-03 17:56:35.689 ERR] 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. 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. ---> Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Transaction (Process ID 72) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Tried adding the following to Startup.cs ConfigureServices(IServiceCollection services). It didn’t help.

services.AddDbContext<umsplusDbContext>(options =>
            {
                options.UseSqlServer(_appConfiguration.GetConnectionString("umsplusDb"),
                    sqlServerOptionsAction: sqlOptions =>
                    {
                        sqlOptions.EnableRetryOnFailure();
                    });
            });

Does this mean ABP framework doesn't support EnableRetryOnFailure?

Since EnableRetryOnFailure doesn't help resolve the issue in this case, please sugest other approaches for investigating this issue.

Please note that there is no issue with running the corresponding raw sql to delete the single enity.

Showing 31 to 31 of 31 entries