Open Closed

OpenIddict TokenProvider Concurrency Exception #7520


User avatar
0
naeem76 created
  • ABP Framework version: v8.2
  • UI Type: MVC
  • Database System: EF Core MySQL
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Getting an error for Concurrency Exception from AbpOpenIddictTokenStore, not sure what is happening, probably due to concurrency stamp, help is appreciated. It's happening after an OAUTH Login callback.

NOTE: running on load balanced environment.

Jul 18 01:47:06 ip-172-31-10-186 web: SELECT `o`.`Id`, `o`.`ApplicationId`, `o`.`AuthorizationId`, `o`.`ConcurrencyStamp`, `o`.`CreationDate`, `o`.`CreationTime`, `o`.`CreatorId`, `o`.`DeleterId`, `o`.`DeletionTime`, `o`.`ExpirationDate`, `o`.`ExtraProperties`, `o`.`IsDeleted`, `o`.`LastModificationTime`, `o`.`LastModifierId`, `o`.`Payload`, `o`.`Properties`, `o`.`RedemptionDate`, `o`.`ReferenceId`, `o`.`Status`, `o`.`Subject`, `o`.`Type`
Jul 18 01:47:06 ip-172-31-10-186 web: FROM `OpenIddictTokens` AS `o`
Jul 18 01:47:06 ip-172-31-10-186 web: WHERE (@__ef_filter__p_0 OR NOT (`o`.`IsDeleted`)) AND (`o`.`Id` = @__id_0)
Jul 18 01:47:06 ip-172-31-10-186 web: ORDER BY `o`.`Id`
Jul 18 01:47:06 ip-172-31-10-186 web: LIMIT 1
Jul 18 01:47:06 ip-172-31-10-186 web: 01:47:06 [INF] Executed DbCommand (16ms) [Parameters=[@p5='?' (DbType = Guid), @p0='?' (Size = 40), @p6='?' (Size = 40), @p1='?' (DbType = DateTime), @p2='?' (DbType = Guid), @p3='?' (Size = 4000), @p4='?' (Size = 100)], CommandType='Text', CommandTimeout='30']
Jul 18 01:47:06 ip-172-31-10-186 web: SET AUTOCOMMIT = 1;
Jul 18 01:47:06 ip-172-31-10-186 web: UPDATE `OpenIddictTokens` SET `ConcurrencyStamp` = @p0, `LastModificationTime` = @p1, `LastModifierId` = @p2, `Payload` = @p3, `ReferenceId` = @p4
Jul 18 01:47:06 ip-172-31-10-186 web: WHERE `Id` = @p5 AND `ConcurrencyStamp` = @p6;
Jul 18 01:47:06 ip-172-31-10-186 web: SELECT ROW_COUNT();
Jul 18 01:47:07 ip-172-31-10-186 web: 01:47:07 [WRN] There is an entry which is not saved due to concurrency exception:
Jul 18 01:47:07 ip-172-31-10-186 web: OpenIddictToken {Id: 3a13d5b2-5f8d-043f-eee2-1bf911ed7bac} Modified FK {ApplicationId: 3a13d507-855b-a008-1d8f-b2b5b6f05b1a} FK {AuthorizationId: 3a13d526-0d0d-ef2d-7bd5-21a0e3c43eda}
Jul 18 01:47:07 ip-172-31-10-186 web: 01:47:07 [ERR] The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
Jul 18 01:47:07 ip-172-31-10-186 web: Volo.Abp.Data.AbpDbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
Jul 18 01:47:07 ip-172-31-10-186 web: ---> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithRowsAffectedOnlyAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: --- End of inner exception stack trace ---
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
Jul 18 01:47:07 ip-172-31-10-186 web: at Volo.Abp.OpenIddict.Tokens.AbpOpenIddictTokenStore.UpdateAsync(OpenIddictTokenModel token, CancellationToken cancellationToken)
Jul 18 01:47:07 ip-172-31-10-186 web: 01:47:07 [INF] Executed action Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) in 4617.1376ms
Jul 18 01:47:07 ip-172-31-10-186 web: 01:47:07 [INF] Executed endpoint 'Volo.Abp.OpenIddict.Controllers.AuthorizeController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore)'

27 Answer(s)
  • User Avatar
    0
    naeem76 created

    The difference between using the proxy is just a connection string in terms of what ABP uses. So not sure why the duplication only on proxy, but willl investigate.

    Thanks for your help, as it's not a problem with ABP, closing this now.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Good news.

Made with ❤️ on ABP v9.0.0-preview Updated on September 19, 2024, 10:13