简体   繁体   中英

OracleModificationCommandBatch.Consume() : Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException

I am using my identity server 4 with a database in Oracle and I am seeing this exception very often even with I have disabled EnableTokenCleanup. I have a load balancer with +1 Identity Server, all those using the same database.

2021-04-07 16:06:29.865 -07:00 [Error] Microsoft.EntityFrameworkCore.Update: 2021-04-07 16:06:29.865449 ThreadID:110 (ERROR) OracleModificationCommandBatch.Consume(): Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. at Oracle.EntityFrameworkCore.Update.Internal.OracleModificationCommandBatch.Consume(RelationalDataReader relationalReader) 2021-04-07 16:06:29.868 -07:00 [Error] Microsoft.EntityFrameworkCore.Update: An exception occurred in the database while saving changes for context type 'IdentityServer4.EntityFramework.DbContexts.PersistedGrantDbContext'. Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. at Oracle.EntityFrameworkCore.Update.Internal.OracleModificationCommandBatch.Consume(RelationalDataReader relationalReader) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(DbContext _, ValueTuple 2 parameters) at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.Execute[TState,TResult](TState state, Func 3 operation, Func 3 verifySucceeded) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable 1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IReadOnlyList 1 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList 1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.Sav eChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded.

My impression is that you will have issues like this if you let multiple instances of IdentityServer to share the same database. Sure, its possible, but I think you need to review the data base queries to make sure they can handle multiple IdentityServers writing to the same database.

I assume IdentityServer was made for one identityServer and one database.

do you really need to have two instances running at the same time? or perhaps better to have one active and one instance standing by to take over if the primary one goes down?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM