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

Use Resolved ObservationRegistry in DataSourceObservationListener bean #56

Open
ttddyy opened this issue Jan 13, 2025 · 0 comments
Open
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ttddyy
Copy link
Member

ttddyy commented Jan 13, 2025

Based on #54, when background entity manager creation is enabled, the EntityManager is created in a separate thread. As part of EntityManager creation, it accesses the database to obtain database metadata. The JDBC access invokes a call to DataSourceObservationListener, which also triggers the ObjectProvider<ObservationRegistry> to lazily retrieve the ObservationRegistry bean for DataSourceObservationListener. Since this call is made in a separate thread, it causes a deadlock in the BeanFactory. (Details described in spring-projects/spring-framework#34247)

Originally, the lazy resolution of ObservationRegistry was introduced to avoid circular references with Micrometer registry, binders, and filters during Spring Boot startup. This behavior was addressed at some point (possibly in this commit).

To address this issue, change the DataSourceObservationListener bean definition to directly use the resolved ObservationRegistry bean instead of relying on ObjectProvider<ObservationRegistry>.

To preserve the existing ObjectProvider-based lazy resolution behavior, it could add a property to toggle this behavior.

@ttddyy ttddyy added the enhancement New feature or request label Jan 13, 2025
@ttddyy ttddyy added this to the v1.1.0 milestone Jan 13, 2025
@ttddyy ttddyy self-assigned this Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant