Skip to content
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

datasource-micrometer is causing application to halt from spring boot 3.4.1 #54

Closed
rajadilipkolli opened this issue Jan 6, 2025 · 3 comments
Labels
question Further information is requested

Comments

@rajadilipkolli
Copy link

rajadilipkolli commented Jan 6, 2025

I have this application with works fine with autoconfiguration of datasource-micrometer till 3.4.0 , the moment I have upgraded to 3.4.1 it is halting and never proceeding further

In src/test/java/com/example/learning/common/AbstractIntegrationTest.java I have added a property to turn on and off for replicating the issue. When autoconfiguration is disabled as default is on, everything works as expected.

@ttddyy
Copy link
Member

ttddyy commented Jan 7, 2025

@rajadilipkolli Thanks for the report and repro.

I debugged it and found this is where the hang happens when running DataSourceObservationListener.

observationRegistrySupplier.get() is a supplier that lazily gets an ObservationRegistry bean.
The actual supplier is a lambda from DataSourceObservationAutoConfiguration#L99 which is an ObjectProvider<ObservationRegistry>.

The DataSourceObservationListener is called while spring is creating a LocalContainerEntityManagerFactoryBean bean in a separate thread and trying to access the database to obtain metadata - AbstractEntityManagerFactoryBean#L397

I suspect there is some locks in spring trying to retrieve a bean via ObjectProvider while another bean(LocalContainerEntityManagerFactoryBean) is in creation.

I need to investigate more details but this is so far what I found.

@ttddyy
Copy link
Member

ttddyy commented Jan 13, 2025

@rajadilipkolli I debugged the root cause and filed spring-projects/spring-framework#34247 where I detailed the deadlock scenario. I also created #56 to improve datasource-micrometer.

To workaround/solve the problem on your app, you need to change the spring.data.jpa.repositories.bootstrap-mode property to default, so that EntityManager and all related beans are created on the main thread.

Since I have created #56, I am closing this issue.

Thanks for your report!!

@ttddyy ttddyy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2025
@ttddyy
Copy link
Member

ttddyy commented Jan 14, 2025

It'll be fixed in Spring Framework 6.2.2 which will be used by Boot 3.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants