Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1729

CronTriggeringPolicy using "evaluateOnStartup" cause dead lock

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.7
    • Fix Version/s: 2.7
    • Component/s: Core
    • Labels:
      None

      Description

      1. There is two classloder. Parent and Child.
      2. Log4j*.jar is loaded by Parent and log4j2.xml is loaded by Child.
      3. The class using log4j is loaded by child.
      4. The threadContextClassLoader is child.
      5. Using "evaluateOnStartup" and the log need rollover on startup.

      Reason:
      Threre creat two LoggerContext. And two context load one config ,all need to rollover the log.

      This is stack:
      "main" prio=10 tid=0x00007f3ce4010000 nid=0x5936 waiting on condition [0x00007f3cebd24000]
      java.lang.Thread.State: WAITING (parking)
      at sun.misc.Unsafe.park(Native Method)

      • parking to wait for <0x00000000d9e17b98> (a java.util.concurrent.Semaphore$NonfairSync)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:994)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1303)
        at java.util.concurrent.Semaphore.acquire(Semaphore.java:317)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:247)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:192)
      • locked <0x00000000d9e179f0> (a org.apache.logging.log4j.core.appender.rolling.RollingFileManager)
        at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.rollover(CronTriggeringPolicy.java:132)
        at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.initialize(CronTriggeringPolicy.java:69)
        at org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy.initialize(CompositeTriggeringPolicy.java:52)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.setTriggeringPolicy(RollingFileManager.java:216)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.updateData(RollingFileManager.java:439)
        at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:119)
        at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:128)
        at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:135)
        at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:1)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:882)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:874)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:498)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:227)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:239)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:530)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:1)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
        at org.apache.logging.log4j.core.LoggerContext.getContext(LoggerContext.java:187)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:272)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:192)
      • locked <0x00000000d9e179f0> (a org.apache.logging.log4j.core.appender.rolling.RollingFileManager)
        at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.rollover(CronTriggeringPolicy.java:132)
        at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.initialize(CronTriggeringPolicy.java:69)
        at org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy.initialize(CompositeTriggeringPolicy.java:52)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.initialize(RollingFileManager.java:104)
        at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:142)
        at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:1)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:882)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:874)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:498)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:227)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:239)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:530)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:1)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
        at org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
        at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
        at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
        at com.h3c.plugin.cp.Cp.<clinit>(Cp.java:10)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at java.lang.Class.newInstance(Class.java:374)
        at com.h3c.classloader.Plugin.loadBean(Plugin.java:36)
        at com.h3c.classloader.Main.testSimple(Main.java:25)
        at com.h3c.classloader.Main.main(Main.java:11)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cpszgy ping cheng
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: