Description
Hi,
We have recently migrated to Spring Boot 3.4.x, which creates and initializes beans in parallel upon startup. We are experiencing problems where some of our Spring Boot applications do not even start. We suspect they are stuck in a deadlock related to this parallel creation and initialization of beans.
We see a lot of the following messages in the logs:
Creating singleton bean 'X' in thread "Y" while other thread holds singleton lock for other beans: [Z, ...]
These are the last log messages we see before the application stops logging and eventually runs in the following:
The XYZ application did not issue the ApplicationReadyEvent event in 5 minutes.
Here is an actual example:
[2025-04-06T23:23:45.453+0200] org.springframework.beans.factory.support.DefaultListableBeanFactory : Creating singleton bean 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration' in thread "Default Executor-thread-4" while other thread holds singleton lock for other beans [org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration, springSecurityFilterChain]
[2025-04-06T23:28:13.754+0200] 0000004a SpringBootApp A CWWKC0264W: The application did not issue the ApplicationReadyEvent event in 5 minutes.
We are concerned by the fact that the last bean that is created before the (supposed) deadlock is (according to the log message) org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration, and this bean is also in the list of beans on which a different thread already holds a lock. This does not seem right and this is not a custom bean. We can see a resemblance with https://github.com/spring-projects/spring-framework/issues/34672, so we plan on giving 6.2.6 a try, unfortunately that's not easy for us to do since the issue only manifests itself in production. We are also working on a way to reproduce it in the lower environments. My question would be, is the concern about the WebSecurityConfiguration bean justified or not? Should the fix in 6.2.6 also work in our case or is this potentially a new issue?
Regards
Calin