You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/11/12 16:49:00 UTC
[jira] [Commented] (LOG4J2-2916) If loggercontext got reconfigured
and kafka appender got recreated, the previous producer can not be closed,
which cause thread leak
[ https://issues.apache.org/jira/browse/LOG4J2-2916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17230772#comment-17230772 ]
ASF subversion and git services commented on LOG4J2-2916:
---------------------------------------------------------
Commit d8c8691917763451aa43a8d00f147d2c6fc799b1 in logging-log4j2's branch refs/heads/master from Volkan Yazıcı
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=d8c8691 ]
LOG4J2-2916 Avoid redundant Kafka producer instantiation causing thread leaks.
> If loggercontext got reconfigured and kafka appender got recreated, the previous producer can not be closed, which cause thread leak
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-2916
> URL: https://issues.apache.org/jira/browse/LOG4J2-2916
> Project: Log4j 2
> Issue Type: Bug
> Reporter: wuqian
> Priority: Major
>
> If loggercontext got reconfigured and kafka appender got recreated, the previous kafka producer thread can not be closed, which cause thread leak
>
> Repeat steps:
> xml configured to use kafka appender
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
>
> Resolution:
> In case the abstractlogmanager always cache the latest new producer and old producer can not be released.
> When creating new kafkamanager, add a logic to release previous kafka producer.
>
> public void startup() {
> // If loggercontext reconfigured and kafka appender got recreated, the previous producer can not be closed
> // which cause thread leak
> if(producer != null){
> producer.close();
> }
> producer = producerFactory.newKafkaProducer(config);
> }
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)