Skip to content

1.0.0.Final cannot connect to the database, but CR10 can #1006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
UkonnRa opened this issue Oct 20, 2021 · 2 comments
Closed

1.0.0.Final cannot connect to the database, but CR10 can #1006

UkonnRa opened this issue Oct 20, 2021 · 2 comments
Assignees

Comments

@UkonnRa
Copy link

UkonnRa commented Oct 20, 2021

Description

When using 1.0.0.Final, SessionFactory cannot be created and blocks the main thread. But 1.0.0.CR10 is still working. Guessing it's related to #995.

Demo

https://github.com/UkonnRa/hibernate-reactive-1_0_0-final-bug-test

By default, it's using 1.0.0.Final, and we can get the blocking error:

...
17:05:04.327 [vert.x-eventloop-thread-1] INFO  org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
17:05:04.476 [vert.x-eventloop-thread-1] INFO  org.hibernate.reactive.provider.impl.ReactiveIntegrator - HR000001: Hibernate Reactive Preview
17:05:04.673 [vert.x-eventloop-thread-1] INFO  org.hibernate.reactive.pool.impl.DefaultSqlClientPool - HR000011: SQL Client URL [jdbc:postgresql://localhost:5432/white-rabbit]
17:05:04.676 [vert.x-eventloop-thread-1] INFO  org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration - HR000025: Connection pool size: 10
17:05:05.405 [vertx-blocked-thread-checker] WARN  io.vertx.core.impl.BlockedThreadChecker - Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 2879 ms, time limit is 2000 ms
17:05:06.405 [vertx-blocked-thread-checker] WARN  io.vertx.core.impl.BlockedThreadChecker - Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 3880 ms, time limit is 2000 ms

But when changing to 1.0.0.CR10, everything works fine.

@DavideD DavideD self-assigned this Oct 20, 2021
@DavideD
Copy link
Member

DavideD commented Oct 20, 2021

Thanks for the feedback and test case.

I've found several issues with the test you have provided, though:

  1. The entity class package in the persistence.xml is wrong. It should be io.vertx.hibernate.Employee.
  2. withSession doesn't flush the session, so the persist wasn't happening. You can solve this by using withTransaction instead. Or you could flush the session after the persist.
  3. The automatic schema creation when the factory is started is a blocking operation, so it needs to be run in vertx.executeBlocking. This is on us because I don't think we mention it in the documentation.

There was probably something else wrong because this test cannot work. It doesn't matter which library version you use.

I did some refactoring and now everything works as expected. You can see that with 1.0.0.Final, it uses the correct Vert.x instance. I've applied the changes (and a bit of refactoring) in this commit: DavideD/hibernate-reactive-1_0_0-final-bug-test@167fbc3.

Please, let me know if you have more questions or something else doesn't work.
I will close this issue for now.

Cheers

@DavideD DavideD closed this as completed Oct 20, 2021
@UkonnRa
Copy link
Author

UkonnRa commented Oct 20, 2021

Thank a lot! The 3rd point is what I did wrong in my own project as well. Now my project is working as expected

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

No branches or pull requests

2 participants