Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 729E918EE9 for ; Thu, 28 May 2015 19:25:19 +0000 (UTC) Received: (qmail 37589 invoked by uid 500); 28 May 2015 19:25:19 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 37545 invoked by uid 500); 28 May 2015 19:25:19 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 37536 invoked by uid 99); 28 May 2015 19:25:19 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 May 2015 19:25:19 +0000 Date: Thu, 28 May 2015 19:25:19 +0000 (UTC) From: "Mariano Gonzalez (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LOG4J2-927) Race condition between a LoggerContext stop() and async loggers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4J2-927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14563528#comment-14563528 ] Mariano Gonzalez commented on LOG4J2-927: ----------------------------------------- still happens in 2.3.. Something I saw in 2.1, is that not all loggers are stopped. In org.apache.logging.log4j.core.config.AbstractConfiguration#stop:251 loggers are not stopped if they're already on a set. However, because the hashCode is based on the state and not the instance itself, only the first logger is stopped and the rest are wrongfully considered as stopped. However, this alone doesn't seem to be enough to fix the issue > Race condition between a LoggerContext stop() and async loggers > --------------------------------------------------------------- > > Key: LOG4J2-927 > URL: https://issues.apache.org/jira/browse/LOG4J2-927 > Project: Log4j 2 > Issue Type: Bug > Components: Appenders > Affects Versions: 2.1 > Reporter: Mariano Gonzalez > > I have an application in which I'm using all async loggers. When I stop the LoggerContext, there're still some events waiting in disruptor's buffer and when it tries to execute them the context is already closed and thus those events are lost. In the case of a RollingFileAppender, I get an IOException because the outputStream has already been closed. > As a debugging technique, I did an Appedder decorator that looks like this: > {code:java} > final class StopConditionSafeAppenderWrapper extends BaseAppenderWrapper > { > private final LoggerContext loggerContext; > StopConditionSafeAppenderWrapper(Appender delegate, LoggerContext loggerContext) > { > super(delegate); > this.loggerContext = loggerContext; > } > @Override > public void append(LogEvent event) > { > if (!loggerContext.isStarted()) { > return; > } > super.append(event); > } > } > {code} > With the help of a debugger, I could verify that when the append method was invoked the loggerContext was started but then by the time the exception occurred it was closed. > It checked the code at LoggerContext#stop() and saw that there's code to prevent disruptor from taking new events once a stop() has been invoked, but there's no code to wait for the ring buffer to be fully consumed before actually stopping. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org