question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

100% CPU when revoking tokens

See original GitHub issue

Confirm you’ve already contributed to this project or that you sponsor it

  • I confirm I’m a sponsor or a contributor

Version

4.x

Describe the bug

My server sometimes goes 100% CPU and I’ve noticed the correlation with 2 logs

The token '{GUID}' was successfully revoked.

and

An exception occurred in the database while saving changes for context type 'Crpg.WebApi.Identity.OpenIddictDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Conflicts were detected for instance of entity type 'OpenIddictEntityFrameworkCoreToken' on the concurrency token properties {'ConcurrencyToken'}. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting values.
 at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryTable`1.ThrowUpdateConcurrencyException(IUpdateEntry entry, Dictionary`2 concurrencyConflicts, IDiagnosticsLogger`1 updateLogger)
 at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryTable`1.Update(IUpdateEntry entry, IDiagnosticsLogger`1 updateLogger)
 at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryStore.ExecuteTransaction(IList`1 entries, IDiagnosticsLogger`1 updateLogger)
 at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryDatabase.SaveChangesAsync(IList`1 entries, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)""","An exception occurred in the database while saving changes for context type 'Crpg.WebApi.Identity.OpenIddictDbContext'.Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Conflicts were detected for instance of entity type 'OpenIddictEntityFrameworkCoreToken' on the concurrency token properties {'ConcurrencyToken'}. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting values. at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryTable`1.ThrowUpdateConcurrencyException(IUpdateEntry entry, Dictionary`2 concurrencyConflicts, IDiagnosticsLogger`1 updateLogger) at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryTable`1.Update(IUpdateEntry entry, IDiagnosticsLogger`1 updateLogger) at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryStore.ExecuteTransaction(IList`1 entries, IDiagnosticsLogger`1 updateLogger) at Microsoft.EntityFrameworkCore.InMemory.Storage.Internal.InMemoryDatabase.SaveChangesAsync(IList`1 entries, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)

Here are the logs filtering on “OpenIddict” or “error”: openiddict-logs.csv.

For info, I’m using the in-memory provider. I’m thinking that maybe the token revocation expects an index so it’s super slow with this provider?

To reproduce

Hard to reproduce. Use this program and make it run for days https://github.com/verdie-g/crpg/blob/844795b4c2b6c32431a4ff6bf75ce938a9a9d72e/src/WebApi/Program.cs

Exceptions (if any)

No response

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinchaletcommented, Aug 4, 2023

@verdie-g makes a lot of sense (tho’ it’s not clear to me why only a single user seems to be affected).

Given it’s likely not an OpenIddict issue at this point, I’m going to close this ticket. I opened https://github.com/openiddict/openiddict-core/issues/1856 to track adding new store methods in 5.0 to make the token chain revocation process much more efficient.

Cheers.

1reaction
kevinchaletcommented, Jul 5, 2023

No, the replay detection/revocation mechanism only kicks in when using an authorization code or refresh token (i.e not when using the client credentials grant)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduce a more efficient way to revoke all the tokens ...
Introduce a more efficient way to revoke all the tokens associated with an authorization #1856. Open. 1 task done ... 100% CPU when...
Read more >
CancellationTokenSource High Cpu Usage
I am trying to cancel my tasks but it creating high cpu usage. My cpu goes to 100% ... Token); Thread.Sleep(100); } }));...
Read more >
100% CPU usage with nothing running : r/techsupport
100 % cpu in task manager when actual tasks only add up to about 30%. Things are very slow to load and it...
Read more >
TokenBroker services causes high CPU utilization?
We have been able to isolate the high CPU to the Token Broker service by using the Windows Performance Recorder and Analyzer.
Read more >
CPU usage is very high
If the level of CPU use is very high, the response times typically become longer for the end user, but the system still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found