Log4j 2
  1. Log4j 2
  2. LOG4J2-738

RollingFileManager deadlock if async action thread fails to start

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-rc1
    • Fix Version/s: 2.0.1
    • Component/s: Appenders
    • Labels:
      None
    • Environment:

      amazon linux

      Description

      The symptom we're seeing is a thread stuck trying to acquire the semaphore in RollingFileManager.rollover(). It looks like the RollingFileManager can fail to release the semaphore if there is an exception during thread start for the async path in the rollover() method.

      I think this is the relevant chunk of code:

                      if (success && descriptor.getAsynchronous() != null) {
                          LOGGER.debug("RollingFileManager executing async {}", descriptor.getAsynchronous());
                          thread = new Thread(new AsyncAction(descriptor.getAsynchronous(), this));
                          thread.start();
                      }
                      return true;
                  }
                  return false;
              } finally {
                  if (thread == null) {
                      semaphore.release();
                  }
              }
      

      So, if thread start fails (because of OOM), the 'thread' variable will be != null and so the semaphore won't be released.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Timothy Stack
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development