-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
apparent deadlock in InternalLoggerRegistry.getLogger() #3252
Comments
As showed in #3252, Spring's `JndiPropertySource` not only can throw exceptions, but can also perform logging calls. Such a call causes a recursive call to `PropertiesUtil.getProperty("log4j2.flowMessageFactory"`) and a `StackOverflowException` in the best scenario. The worst scenario includes a deadlock. This PR: - Moves the creation of the default `MessageFactory` and `FlowMessageFactory` to the static initializer of `LoggerContext`. This should be close enough to the pre-2.23.0 location in `AbstractLogger`. The `LoggerContext` class is usually initialized, before Spring Boot adds its property sources to `PropertiesUtil`. - Adds a check to `PropertiesUtil` to ignore recursive calls. Closes #3252.
This is a real deadlock caused by a recursive call between the Log4j
This cycle should explain both the deadlock and the stack overflow. PR #3263 will eliminate the stack overflow and the dead lock. In the meantime you can:
|
Can you check if our |
@ppkarwasz yes, I think I can try that fairly easily for you this morning; will circle back as soon as I know. |
@ppkarwasz sorry for the delay; getting our cicd to pick up snapshots end-to-end was more challenging than I expected, but I learned some things :). In any case, all our basic sanity checks / regression tests pass with this snapshot; I think it solves our problem - thank you! |
Thanks, I started a Log4j |
Description
SpringBoot 3.x application experiences deadlock/hang at startup with ActiveMQ Artemis and log4j2.
Deadlock occurs if SpringBoot
backend-preinit
is enabled (the default); if disabled, it causes a stackoverflow instead. Both stacktraces are attached.Best guess from our team is that it may relate to weak references in
InternalLoggerRegistry
andLoggerContext
use ofcomputeIfAbsent()
. The speculation is that if a registered logger is released as a weak reference during initialization, then it may be repeatedly initialized - causing aconcurrency/deadlock issue.Configuration
Version: 2.24.2
Operating system: Windows 10 (observed on Alma Linux as well)
JDK: Eclipse Temurin 17.0.8.1
Logs
with
backend-preinit
enabled:with
backend-preinit
disabled:Reproduction
This happens consistently on startup of our SpringBoot 3.x application with Artemis 2.38 and Log4j 2.24.2 .
The text was updated successfully, but these errors were encountered: