gorm-hibernate5 icon indicating copy to clipboard operation
gorm-hibernate5 copied to clipboard

Slow application startup time due to increased datasource configuration time

Open puneetbehl opened this issue 3 years ago • 2 comments

When using the old version 7.3.0, the application starts up in ~4 minutes. But when using the newer version that the Grails cli defaults to for a Grails 4.1.1 application (which is hibernate-core:5.4.18.Final), it takes the application >15 minutes to start.

The application is using Multi-Tenancy with over 40 datasources. In 4.0.3/GORM 7.0.4/Hibernate 5.4.0, it takes ~6--7 seconds to configure each datasource. We are trying to move the app to 4.1.1/GORM 7.0.9/Hibernate 5.4.18. With that configuration, each datasource is now taking ~20-25 seconds to configure.

We've noticed that if we go back to Hibernate 5.4.0 we get the old faster startup time, however there are places in the code where we do the following:

MultiTenantDomain.withSession { Session session->
    session.doWork(...
}

Which now appears to throw an exception of

Caused by: java.lang.NoSuchMethodError: 'void org.hibernate.SharedSessionContract.doWork(org.hibernate.jdbc.Work)'

Originally report by billgonemad and osh Overbeck on Grails Slack.

puneetbehl avatar Aug 31 '22 05:08 puneetbehl

Hibernate 5.4.11 is the first version of hibernate where the start-up slows down considerably. unfortunately, we are still getting the exception with 5.4.10

puneetbehl avatar Aug 31 '22 05:08 puneetbehl

@puneetbehl We were able to get Hibernate 5.4.0 to work. The method throwing the exception was annotated with @GrailsCompileStatic and removing that seems to fix the issue with using the older hibernate version.

billgonemad avatar Aug 31 '22 11:08 billgonemad