8000 Change the flush mode to auto and fixing check for entities loaded into the session by pedroigor · Pull Request #10623 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Change the flush mode to auto and fixing check for entities loaded into the session - #10623

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
pedroigor:issue-10411
Mar 11, 2022
Merged

pedroigor merged 1 commit into
keycloak:mainfrom
pedroigor:issue-10411

Conversation

@pedroigor
@pedroigor pedroigor commented Mar 7, 2022 •
Copy link
Copy Markdown
Contributor

Closes #10411

  • Basically, forces the FlushMode.AUTO similarly to Wildfly dist. By default, it is set to ALWAYS.
  • Fixes the JpaUserProvider to not use PersistenceUnitUtil.isLoaded but EntityManager.contains to check whether entities are loaded into the session

The second one is what behaves differently between Wildfly and Quarkus distribution, Hibernate v5.3 and v5.6, respectively. Accordingly to Hibernate team the usage of PersistenceUnitUtil is not reliable. See https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/main/java/org/hibernate/jpa/internal/PersistenceUnitUtilImpl.java#L40.

@pedroigor pedroigor changed the title Change the flush mode to commit Change the flush mode to auto Mar 7, 2022
DGuhr
DGuhr previously approved these changes Mar 7, 2022
@DGuhr DGuhr left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@pedroigor pedroigor changed the title Change the flush mode to auto Change the flush mode to auto and fixing check for entities loaded into the session Mar 7, 2022
DGuhr
DGuhr previously approved these changes Mar 8, 2022
@abstractj abstractj added the area/dist/quarkus Quarkus distribution — packaging, container images, server config (kc.sh) label Mar 8, 2022
@abstractj
Copy link
Copy Markdown
Contributor

@pedroigor could you please rebase, so I can get it merged?

@stianst stianst left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should get someone from @keycloak/storage-x or @mposolda to review this one

@pedroigor
Copy link
Copy Markdown
Contributor Author

@abstractj Done.

@abstractj
abstractj requested review from mhajas and mposolda March 8, 2022 16:07
@mhajas
mhajas requested a review from vramik March 9, 2022 08:19
@vramik vramik left a comment •
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @pedroigor. I can see there is ongoing discussion at #10411.

In the meantime I checked the PR and it looks good to me. I was trying to debug it locally to see what is going on with the FlushMode. Please see inline for details. Thanks again.

entityManager = PersistenceExceptionConverter.create(session, emf.createEntityManager());
}

entityManager.setFlushMode(FlushModeType.AUTO);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I debug[1] it locally AUTO mode is already set. As far as I was able to find out AUTO is default. Am I missing something?

[1]

cd quarkus
mvn -f server/pom.xml -Dsuspend=true compile quarkus:dev -Dquarkus.args="start-dev"

@pedroigor
Copy link
Copy Markdown
Contributor Author

@vramik Thanks. No, you are not. And the reason is that we are building the EM by ourselves instead of obtaining it from the corresponding extension.

The reason I'm forcing the flush mode is to make more clear the mode we are supposed to use, regardless of how the EM is obtained.

8000

@vramik vramik left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pedroigor thanks. It makes sense.

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

Labels

area/dist/quarkus Quarkus distribution — packaging, container images, server config (kc.sh)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the flush mode to auto

5 participants

0