Skip to content

Hang on AbstractEntityManagerFactoryBean.getNativeEntityManagerFactory() #23735

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
izeye opened this issue Oct 18, 2020 · 3 comments
Closed

Hang on AbstractEntityManagerFactoryBean.getNativeEntityManagerFactory() #23735

izeye opened this issue Oct 18, 2020 · 3 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@izeye
Copy link
Contributor

izeye commented Oct 18, 2020

Upgrading from Spring Boot 2.4.0-M3 to 2.4.0-M4 causes a hang on AbstractEntityManagerFactoryBean.getNativeEntityManagerFactory().

A thread dump of main thread when the hang happens is as follows:

"main" #1 prio=5 os_prio=31 cpu=2876.69ms elapsed=25.68s tid=0x00007fa1f9808a00 nid=0x2703 waiting on condition  [0x0000700007308000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x00000007015a62f0> (a java.util.concurrent.FutureTask)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:211)
        at java.util.concurrent.FutureTask.awaitDone(java.base@15/FutureTask.java:447)
        at java.util.concurrent.FutureTask.get(java.base@15/FutureTask.java:190)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.getNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:560)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:516)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:731)
        at com.sun.proxy.$Proxy76.getStatistics(Unknown Source)
        at io.micrometer.core.instrument.binder.jpa.HibernateMetrics.<init>(HibernateMetrics.java:110)
        at org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration.bindEntityManagerFactoryToRegistry(HibernateMetricsAutoConfiguration.java:68)
        at org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration.lambda$bindEntityManagerFactoriesToRegistry$0(HibernateMetricsAutoConfiguration.java:60)
        at org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration$$Lambda$880/0x0000000800fdfd88.accept(Unknown Source)
        at java.util.LinkedHashMap.forEach(java.base@15/LinkedHashMap.java:723)
        at org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration.bindEntityManagerFactoriesToRegistry(HibernateMetricsAutoConfiguration.java:60)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@15/Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@15/NativeMethodAccessorImpl.java:64)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@15/DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(java.base@15/Method.java:564)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:755)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$246/0x0000000800cbf920.getObject(Unknown Source)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        - locked <0x000000070066dbc8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
        - locked <0x0000000700666de0> (a java.lang.Object)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:418)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
        at com.izeye.mydictionary.MyDictionaryApplication.main(MyDictionaryApplication.java:31)

This is a project that can be used to reproduce it: https://github.com/izeye/my-dictionary/tree/spring-boot-gh-23735 (spring-boot-gh-23735 branch)

Just running it as follows causes a hang:

./gradlew clean bootRun
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 18, 2020
@snicoll
Copy link
Member

snicoll commented Oct 18, 2020

Thanks @izeye. You can workaround the problem for now by adding spring.data.jpa.repositories.bootstrap-mode=default to your configuration

@jhoeller it looks like the fix to let us run database init as part of the EMF lock leads to another problem.

@snicoll
Copy link
Member

snicoll commented Oct 18, 2020

I've created spring-projects/spring-framework#25930

izeye added a commit to izeye/my-dictionary that referenced this issue Oct 18, 2020
@snicoll snicoll added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 19, 2020
@snicoll snicoll added this to the 2.4.0-RC1 milestone Oct 19, 2020
@snicoll snicoll self-assigned this Oct 19, 2020
@snicoll
Copy link
Member

snicoll commented Oct 19, 2020

The fix was applied in 2.3.x but we haven't released it yet hopefully so I've created a task to revisit the fix (#23740). On 2.4.x this is considered as a regression .

snicoll added a commit to snicoll/spring-boot that referenced this issue Oct 19, 2020
izeye added a commit to izeye/my-dictionary that referenced this issue Oct 30, 2020
This commit also removes a workaround for spring-projects/spring-boot#23735 and adds spring.datasource.username property to work with the changes made in spring-projects/spring-boot#23693.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants