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

Skip to content

Conversation

@rmartinc
Copy link
Contributor

@rmartinc rmartinc commented Sep 6, 2021

Issue: https://issues.redhat.com/browse/KEYCLOAK-18842

The deleteExpiredClientSessions query is removed from the annotation and it's added via property files calling the addNamedQuery method at initializing the JPA provider (quarkus or wildfly). The files are placed inside the model-jpa jar and there should be a queries-default.properties and it can be overloaded by a queries-<dbtype>.properties file (the specific file can contain only part of the needed queries). Right now the files just contain the delete query in the two forms, jpql for the default file and native for mysql/mariadb databases.

When HHH-14796 is fixed the annotation for deleteExpiredClientSessions can be restored and the default file will be unnecessary, the default annotation queries will be replaced using the ones in the specific database file directly.

Comments are welcomed! @hmlnarik take a look to the PR when you have time.

Thanks!

@hmlnarik hmlnarik self-assigned this Sep 6, 2021
@hmlnarik hmlnarik added the area/storage Indicates an issue that touches storage (change in data layout or data manipulation) label Sep 6, 2021
@hmlnarik hmlnarik requested a review from vramik September 6, 2021 08:55
Copy link
Contributor

@vramik vramik 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 @rmartinc for the changes. The PR looks very good to me. I wonder if we should also add a note to documentation that it's now possible to override specific query depending the database.

Keycloak allows adding custom Jpa Entities to the keycloak data model: https://www.keycloak.org/docs/latest/server_development/index.html#_extensions_jpa (but it is marked as unsupported in docs) and if I understand correctly this feature could be also applicable to these custom entities.

@rmartinc @hmlnarik wdyt?

@vramik
Copy link
Contributor

vramik commented Sep 7, 2021

@hmlnarik
Copy link
Contributor

@hmlnarik hmlnarik merged commit 47484c1 into keycloak:master Sep 10, 2021
@hmlnarik
Copy link
Contributor

Thanks @rmartinc for the contribution!

return em;
}

private void addSpecificNamedQueries(KeycloakSession session, Connection connection) {
Copy link
Contributor

@pedroigor pedroigor Sep 10, 2021

Choose a reason for hiding this comment

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

@hmlnarik @rmartinc We should avoid whenever possible performing blocking/costly operations during startup. Created https://issues.redhat.com/browse/KEYCLOAK-19274.

Also, would be possible to just use the connection metadata to obtain the database type rather than querying the liquibase provider? Asking because Liquibase operations are usually costly.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. Should be done in augmentation. I wonder if this is / should be done for the whole quarkus/runtime/src/main/java/org/keycloak/connections/jpa/QuarkusJpaConnectionProviderFactory.java?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah ... There are other parts of the code that we can move to build time. For instance, anything that touches upgrade/migration should happen when re-augmenting the server. That could be done once (or manually triggered by the user) and just leave the very necessary bits to the runtime.

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

Labels

area/storage Indicates an issue that touches storage (change in data layout or data manipulation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants