fix: add index on requested_at for refresh tokens and use it in janitor#3516
Merged
aeneasr merged 2 commits intoory:masterfrom May 24, 2023
sgal:fix-refresh-janitororder-by-requested-at
Merged
fix: add index on requested_at for refresh tokens and use it in janitor#3516aeneasr merged 2 commits intoory:masterfrom sgal:fix-refresh-janitororder-by-requested-at
aeneasr merged 2 commits intoory:masterfrom
sgal:fix-refresh-janitororder-by-requested-at
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3516 +/- ##
==========================================
- Coverage 76.89% 76.85% -0.05%
==========================================
Files 124 124
Lines 9102 9175 +73
==========================================
+ Hits 6999 7051 +52
- Misses 1660 1673 +13
- Partials 443 451 +8
|
Member
|
May I suggest adding nid as the index as well, given that it's part of the query in question? |
Contributor
Author
|
@aeneasr Do you mean as a separate index or part of the The composite one was suggested by @arnolf here #3115 (comment) |
Member
|
Like below :) |
Contributor
Author
|
@aeneasr Please have a look, I fixed the index. |
Contributor
hperl
approved these changes
May 24, 2023
Contributor
hperl
left a comment
There was a problem hiding this comment.
LGTM! 🎉
Thanks for the contribution!
aeneasr
approved these changes
May 24, 2023
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue(s)
Inspired by #3115
This change addresses the performance issue with Hydra Janitor, which makes the cleanups extremely slow due to inefficient query that leads to a full table scan.
The approach here is taken from the issue above. Adding an index on the
requested_atfield and ordering by it in Janitor avoids full table scan and improves the performance of the cleanups.Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments
When we run the following query:
We get the following plan, with an execution time of 2.6 seconds. So 2,6 seconds to delete 100 refresh tokens. We can note here that there is a very high cost of the index scan with a lot of filtered rows.
Just to confirm, we also checked the distribution of refresh tokens over the dates, but looks good:
To resolve the issue, we applied an index to the refresh token table:
When we now try to run the cleanup query, and instead change the order by from signature to requested_at
We get a much more healthy execution with 720 hours interval: