Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 560E0200C1D for ; Thu, 2 Feb 2017 01:15:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 54ACC160B5E; Thu, 2 Feb 2017 00:15:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9F1E2160B46 for ; Thu, 2 Feb 2017 01:15:00 +0100 (CET) Received: (qmail 67029 invoked by uid 500); 2 Feb 2017 00:14:59 -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 67020 invoked by uid 99); 2 Feb 2017 00:14:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Feb 2017 00:14:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 511861A020D for ; Thu, 2 Feb 2017 00:14:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 7GPfxLcEoy8r for ; Thu, 2 Feb 2017 00:14:58 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 776A85FDC5 for ; Thu, 2 Feb 2017 00:14:57 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 3B844E0236 for ; Thu, 2 Feb 2017 00:14:53 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 74ADB2527C for ; Thu, 2 Feb 2017 00:14:52 +0000 (UTC) Date: Thu, 2 Feb 2017 00:14:51 +0000 (UTC) From: "Remko Popma (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (LOG4J2-1760) AsyncAppender with LinkedTransferQueue.offer() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 02 Feb 2017 00:15:01 -0000 [ https://issues.apache.org/jira/browse/LOG4J2-1760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15849157#comment-15849157 ] Remko Popma edited comment on LOG4J2-1760 at 2/2/17 12:14 AM: -------------------------------------------------------------- Thanks for the clarification. I looked at the code and I agree there is a problem: in the current code when {{tryTransfer}} fails (because the background thread is busy with the previous event), the current event will be delegated to the {{AsyncQueueFullPolicy}}. The default policy bypasses the queue and appends directly to the underlying appender. Effectively the queue size is zero. This can be improved. As an alternative, when {{tryTransfer}} returns true, AsyncAppender could inspect the queue size and only delegate to the AsyncQueueFullPolicy when the size exceeds the configured max, otherwise enqueue the event with {{offer}}. I need to check the semantics for LinkedTransferQueue::size, some imprecision is acceptable but performance impact is not. Meanwhile, you can work around the issue by configuring the AsyncQueueFullPolicy to enqueue the event: set system property {{log4j2.AsyncQueueFullPolicy}} to {{Discard}} and set {{log4j2.DiscardThreshold}} to a value that doesn't discard any events. (Away from pc, don't remember if it's ALL or NONE.) was (Author: remkop@yahoo.com): Thanks for the clarification. I looked at the code and I agree there is a problem: in the current code when {{tryTransfer}} fails (because the background thread is busy with the previous event), the current event will be delegated to the {{AsyncQueueFullPolicy}}. The default policy bypasses the queue and appends directly to the underlying appender. This can be improved. As an alternative, when {{tryTransfer}} returns true, AsyncAppender could inspect the queue size and only delegate to the AsyncQueueFullPolicy when the size exceeds the configured max, otherwise enqueue the event with {{offer}}. I need to check the semantics for LinkedTransferQueue::size, some imprecision is acceptable but performance impact is not. Meanwhile, you can work around the issue by configuring the AsyncQueueFullPolicy to enqueue the event: set system property {{log4j2.AsyncQueueFullPolicy}} to {{Discard}} and set {{log4j2.DiscardThreshold}} to a value that doesn't discard any events. (Away from pc, don't remember if it's ALL or NONE.) > AsyncAppender with LinkedTransferQueue.offer() > ---------------------------------------------- > > Key: LOG4J2-1760 > URL: https://issues.apache.org/jira/browse/LOG4J2-1760 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders > Affects Versions: 2.7 > Reporter: Addison Walterson > Priority: Minor > > I suggest that the AsyncAppender can use a LinkedTransferQueue for which offer() is used to enqueue messages because tryTransfer() only succeeds if the receiving thread waits for a message which means that the queue has length 0. -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org