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.

Specific token query performance issue

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

3.x

Question

We’ve had issues where our OpenIddict 3.1.1 server periodically completely crashes due to query timeouts on a specific query. The database usage does not exceed 25%, so I’m doubtful it’s caused by a database issue.

The query that seems to be causing the issues is: (@__key_0 uniqueidentifier) SELECT [t].[Id], [t].[ApplicationId], [t].[AuthorizationId], [t].[ConcurrencyToken], [t].[CreationDate], [t].[ExpirationDate], [t].[Payload], [t].[Properties], [t].[RedemptionDate], [t].[ReferenceId], [t].[Status], [t].[Subject], [t].[Type], [t0].[Id], [t0].[ClientId], [t0].[ClientSecret], [t0].[ConcurrencyToken], [t0].[ConsentType], [t0].[CreatedBy], [t0].[CreatedOn], [t0].[DeleteOn], [t0].[DeletedBy], [t0].[DisplayName], [t0].[DisplayNames], [t0].[IsDeleted], [t0].[ModifiedBy], [t0].[ModifiedOn], [t0].[Permissions], [t0].[PostLogoutRedirectUris], [t0].[Properties], [t0].[RedirectUris], [t0].[Requirements], [t0].[Type], [a].[Id], [a].[ApplicationId], [a].[ConcurrencyToken], [a].[CreationDate], [a].[Properties], [a].[Scopes], [a].[Status], [a].[Subject], [a].[Type] FROM [Tokens] AS [t] LEFT JOIN [Authorizations] AS [a] ON [t].[AuthorizationId] = [a].[Id] INNER JOIN [Authorizations] AS [a0] ON [a].[Id] = [a0].[Id] LEFT JOIN (SELECT [a1].[Id], [a1].[ClientId], [a1].[ClientSecret], [a1].[ConcurrencyToken], [a1].[ConsentType], [a1].[CreatedBy], [a1].[CreatedOn], [a1].[DeleteOn], [a1].[DeletedBy], [a1].[DisplayName], [a1].[DisplayNames], [a1].[IsDeleted], [a1].[ModifiedBy], [a1].[ModifiedOn], [a1].[Permissions], [a1].[PostLogoutRedirectUris], [a1].[Properties], [a1].[RedirectUris], [a1].[Requirements], [a1].[Type] FROM [Applications] AS [a1] WHERE [a1].[IsDeleted] <> CAST(1 AS bit)) AS [t0] ON [t].[ApplicationId] = [t0].[Id] WHERE [a0].[Id] = @__key_0

As you can see in the image below, this specific query only gets executed at strange intervals, sometimes causing the server to completely crash due to the timeouts. MicrosoftTeams-image

I have not been able to find what endpoint is executing this query at all, and why it would trigger these timeouts. When I execute the query on the same database manually, no timeouts occur and results are returned as quick as one would expect (<1s).

The data packages I’m using are shown below: afbeelding

Let me know if you need any more information.

Could you point me in the right direction as to where to start looking?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinchaletcommented, Feb 2, 2022

https://github.com/openiddict/openiddict-documentation/issues/38 tracks the work needed to document that. Let me know if you’d be interested in contributing! 😃

1reaction
BlackSyccommented, Feb 2, 2022

Ah it seems I completely missed that part.

I will add the pruning job through Quartz, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance issues can be caused by excessive entries in ...
Performance issues such as high CPU and increased memory use, can be caused by excessive entries in TokenAndPermUserStore cache. By default, ...
Read more >
Query Performance issues associated with a large sized ...
The problems we have seen are specific to token type TokenAccessResult with a class of 65535. These tokens represent information about ...
Read more >
Performance of token range based queries on partition keys?
I am selecting all records from cassandra nodes based on token range of my partition key. ... getTokenRanges gives me all token range...
Read more >
Performance issues due to USERSTORE_TOKENPERM
These issues can include performance degradation of queries, high CPU usage for the SQL Server process, and a sharp increase in worker threads ......
Read more >
Token Best Practices
Lists best practices when using tokens in authentication and ... Add the bare minimum number of claims to the payload for best performance...
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