Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
JDK11 has removed some classes used by log4j2 to initialize logging contexts. Now log4j2 uses StackWalker to discover where it has been instantiated. StackWalker is apparently very expensive.
Kafka has a Logging trait. Classes which want to log application messages get access to the methods provided by the trait by mixing them in using "with Logging". When this is done on scala object (a singleton) this is fine as the logging context in the Logging trait is only initialized at most once. When this is done on class (e.g. class X extends Logging) the logging context is potentially created for each instance. The logging context is needed to determine if a log message will be emitted. So if the method debug("log me") is called the logging context is still initialized to determine if debug logging is enabled. Initializing the logging context calls StackWalker. This can't be avoided even if the log message would never be written to the log.
IncrementalFetchContext is one such class that is inheriting from Logging and incurring a very high cpu cost. It also does this inside of locks.
Attachments
Issue Links
- blocks
-
KAFKA-9366 Upgrade log4j to log4j2
- In Progress
- relates to
-
KAFKA-15141 High CPU usage with log4j2
- Resolved
- links to