Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rmartinc
Copy link
Contributor

@rmartinc rmartinc commented Jul 5, 2024

Closes #30992

The PR adds an index in table USER_CONSENT_CLIENT_SCOPE to improve performance of deleting consents consents when a client scope (or the full realm) is removed. We also need the mariadb/mysql trick to avoid sub-queries (issue https://jira.mariadb.org/browse/MDEV-21012). There are a lot of delete queries with this format, so we can be affected by this in other places. The HHH-14796 issue was fixed long ago so I also improved the custom queries to just define the specific ones. Now the queries are defined via annotations in code normally but they can be overridden in the db properties file.

I create several realms to a total of 0.5M consents in USER_CONSENT_CLIENT_SCOPE. 100K in USER_CONSENT. And removing a new realm was improved from 8.18s to 0.8s. With an empty database the deletion time is around 0.4s. So we are reducing times by ten. As commented we have more queries (delete ones mainly) that follow the same subquery sntax (mainly they cannot be rewritten because its how hibernate constructs them when there is a join in the delete statement).

Finally it was decided to include the index in 18.x for backports. Release notes created for 25.0.2. If we don't reach that release I will move to the next version.

@ahus1 FYI.

@rmartinc rmartinc requested a review from a team as a code owner July 5, 2024 08:48
Copy link
Contributor

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. I was first confused by the other changes around persistent client sessions that are not related to the original issue and I needed for a quiet moment to review this.

I agree that this is the fix KC25+26, and the clean-up makes sense now that the hibernate fix is in place.

When you then backport this change, I suggest to drop the changes that are not relevant to the original issue from it to reduce possible side effects and merge conflicts. For example with the persistent sessions, you'll find that those queries are AFAIK different in KC24 due to some changes around persistent sessions I prepared for KC25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Realm cannot be deleted if there are tons of consents

2 participants