Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNGIwOTRlY2E1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16150?atlOrigin=eyJpIjoiNGIwOT...
) HHH-16150 (
https://hibernate.atlassian.net/browse/HHH-16150?atlOrigin=eyJpIjoiNGIwOT...
) Hibernate ORM no longer drops the schema when using the create-drop strategy and a
session factory observer throws an exception on startup (
https://hibernate.atlassian.net/browse/HHH-16150?atlOrigin=eyJpIjoiNGIwOT...
)
Issue Type: Bug Affects Versions: 6.2.0.CR2 Assignee: Unassigned Components:
hibernate-core Created: 07/Feb/2023 04:12 AM Fix Versions: 6.2.0 Priority: Major Reporter:
Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Regression in ORM 6. I think it’s specific to ORM 6.2, because I’ve never encountered this
problem with ORM 6.0/6.1, but I’m not 100% sure (maybe the problem just wasn’t as visible
in Hibernate Search before).
The scenario:
* Hibernate ORM boots. While building the session factory, it calls sessionFactoryCreated
on all session factory observers.
* In ORM 6.2, this means in particular calling
org.hibernate.boot.internal.SessionFactoryObserverForSchemaExport#sessionFactoryCreated ,
which successfully creates the DB schema.
* One of the next observers (say, Hibernate Search’s) throws an exception from
sessionFactoryCreated (say, because the Hibernate Search mapping is invalid).
* Hibernate ORM catches that exception and attempts to close the session factory.
* Upon closing, the session factory calls sessionFactoryClosing on all session factory
observers.
* In ORM 6.2, this means in particular calling
org.hibernate.boot.internal.SessionFactoryObserverForSchemaExport#sessionFactoryClosing.
That last call fails with the following exception:
org.hibernate.service.UnknownServiceException: Unknown service requested
[org.hibernate.engine.jdbc.spi.JdbcServices]
at
org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:212)
at
org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:100)
at
org.hibernate.tool.schema.internal.SchemaDropperImpl$DelayedDropActionImpl$JdbcContextDelayedDropImpl.<init>(SchemaDropperImpl.java:677)
at
org.hibernate.tool.schema.internal.SchemaDropperImpl$DelayedDropActionImpl.perform(SchemaDropperImpl.java:641)
at
org.hibernate.boot.internal.SessionFactoryObserverForSchemaExport.sessionFactoryClosing(SessionFactoryObserverForSchemaExport.java:48)
at
org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryClosing(SessionFactoryObserverChain.java:48)
at org.hibernate.internal.SessionFactoryImpl.close(SessionFactoryImpl.java:838)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:377)
In Hibernate ORM 5, things were a bit different (e.g. schema creation/drop was not done in
an observer, see
https://github.com/hibernate/hibernate-search/pull/3396/commits/9b18a1ed3...
(
https://github.com/hibernate/hibernate-search/pull/3396/commits/9b18a1ed3...
) ), so it’s hard to pinpoint where the problem was introduced exactly; but I can say at
least that we didn’t get that exception in Hibernate ORM 5 and the schema was properly
dropped.
I believe the problem is here:
https://github.com/hibernate/hibernate-orm/blob/63715770e94f18137d9d63f7d...
(
https://github.com/hibernate/hibernate-orm/blob/63715770e94f18137d9d63f7d...
)
It seems odd that we close the service registry after closing each integrator? I’d expect
closing the service registry to be one of the very last things we do.
(
https://hibernate.atlassian.net/browse/HHH-16150#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16150#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:c33f0bb )