Specific token query performance issue
See original GitHub issueConfirm 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.
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:
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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
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! 😃
Ah it seems I completely missed that part.
I will add the pruning job through Quartz, thank you!