-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Change how JPAConfig cleans up its resources #46357
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
base: main
Are you sure you want to change the base?
Change how JPAConfig cleans up its resources #46357
Conversation
/cc @gsmet (hibernate-orm,hibernate-search) |
🎊 PR Preview 1a01fee has been successfully built and deployed to https://quarkus-pr-main-46357-preview.surge.sh/version/main/guides/
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
IMO introducing priorities makes sense and we definitely should go in this direction.
But...
First, we'd need more careful definition/documentation :)
Second, and more importantly, I wonder if this isn't stopping short of what we really need. For example shouldn't we tie startup order to this? It kind of makes sense that components should be shut down in the opposite order they started in, especially for synthetic beans using .startup()
(like datasources).
We could imagine something like:
- Startup of components outside of CDI
- Startup of Quarkus "core" CDI beans
- Startup of Quarkus "extension" CDI beans, in particular:
- Startup of Datasources
- Startup of Hibernate
- Startup of application beans
- Shutdown of application beans
- Shutdown of Quarkus "extension" CDI beans, in particular:
- Shutdown of Hibernate
- Shutdown of Datasources
- Shutdown of Quarkus "core" CDI beans
- Shutdown of components outside of CDI
... which looks a lot like Intereceptor.Priority
, but probably shouldn't be based on it, because I think items 1 & 9 are extra.
What your PR covers is, I think, items 5/6. I'm fine with starting with that, but we should probably raise the issue to others, and perhaps make sure that the priorities we'll pick here will make sense when/if we extend your work to all startup/shutdown.
core/runtime/src/main/java/io/quarkus/runtime/ShutdownContext.java
Outdated
Show resolved
Hide resolved
core/runtime/src/main/java/io/quarkus/runtime/ShutdownContext.java
Outdated
Show resolved
Hide resolved
core/runtime/src/main/java/io/quarkus/runtime/StartupContext.java
Outdated
Show resolved
Hide resolved
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-internal</artifactId> | ||
<scope>test</scope> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is suspicious... integration tests should be like an application, so shouldn't need to rely on "internal" modules?
Did you try putting these tests in extensions/hibernate-search-orm-elasticsearch-outbox-polling/deployment
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is apparently still relevant... maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, thanks 😃
moved them around and it worked (at least locally) let's see what CI says 🤞🏻 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh and there are more changes in main now 😁 let me rebase ....
...bernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRecorder.java
Outdated
Show resolved
Hide resolved
core/runtime/src/main/java/io/quarkus/runtime/StartupContext.java
Outdated
Show resolved
Hide resolved
1000000000000000000% 😄 I just wanted to push this out as an idea and have something to start the discussion around 😃.
yeah, there are all sorts of flavours for these shutdown things, there are observers for a shutdown event, there are shutdown so my thinking here was that on shutdown we:
so I'd create a priority range for these groups and then use that. |
Fine by me, but like I said this needs to take into account future changes, because changing these constants later will be painful. In particular:
With that in mind, something similarly generic to
We'd get this startup order:
And this shutdown order:
Obviously calling it "Shutdown priorities" will be a bit weird :] But... would that fit what you're trying to do with shutdown? Ah, also... I suspect this is something that needs discussing on the quarkus-dev mailing list. Let's plan that on Zulip. |
06f5835
to
c08b914
Compare
+1 I think ordering the transaction recovery system early during startup and late during shutdown is needed (for example it should help with #35839 (comment) |
44c2ccb
to
7920a7d
Compare
7920a7d
to
b8742be
Compare
This comment has been minimized.
This comment has been minimized.
...bernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRecorder.java
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
FYI @mmusgrov Marko changed the approach completely, to only address the specific case of Hibernate. This follows the discussion on quarkus-dev: https://groups.google.com/g/quarkus-dev/c/CMq7i4EZMXY/m/vy956nJjBwAJ EDIT: Sorry, wrong link -- I fixed it. |
b8742be
to
cee9d0b
Compare
cee9d0b
to
f30b4ed
Compare
Status for workflow
|
Status for workflow
|
this is an alternative to #45451.
Adding a priority to shutdown tasks allows us to have a better understanding of how those will be executed. Having the task firing the shutdown event as the first one in that queue seemed reasonable; that way, those handling this event will not be in a situation where something gets shut down before the event handler can use it.
Then, for the ORM-specific part, we add a shutdown task when we create a JPA config, and the cleanup of PUs will only close those that actually correctly started.
I thought about removing the
lastShutdownTasks
queue and just handling that through priority, but then ... I didn't want to change too much 😄 so I've kept it for now.