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 80976200D4A for ; Tue, 28 Nov 2017 10:46:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7F0D8160C15; Tue, 28 Nov 2017 09:46:04 +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 C532F160C07 for ; Tue, 28 Nov 2017 10:46:03 +0100 (CET) Received: (qmail 83937 invoked by uid 500); 28 Nov 2017 09:46:03 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 83928 invoked by uid 99); 28 Nov 2017 09:46:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2017 09:46:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 1E52318071A for ; Tue, 28 Nov 2017 09:46:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 29_s5D2HS23s for ; Tue, 28 Nov 2017 09:46:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id BCDB75F232 for ; Tue, 28 Nov 2017 09:46:00 +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 51DB1E015F for ; Tue, 28 Nov 2017 09:46:00 +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 124B3241C0 for ; Tue, 28 Nov 2017 09:46:00 +0000 (UTC) Date: Tue, 28 Nov 2017 09:46:00 +0000 (UTC) From: "Tolstopyatov Vsevolod (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SPARK-22625) Properly cleanup inheritable thread-locals MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 28 Nov 2017 09:46:04 -0000 [ https://issues.apache.org/jira/browse/SPARK-22625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tolstopyatov Vsevolod updated SPARK-22625: ------------------------------------------ Description: Memory leak is present due to inherited thread locals, SPARK-20558 didn't fixed it properly. Our production application has the following logic: one thread is reading from HDFS and another one creates spark context, processes HDFS files and then closes it on regular schedule. Depending on what thread started first, SparkContext thread local may or may not be inherited by HDFS-daemon (DataStreamer), causing memory leak when streamer was created after spark context. Memory consumption increases every time new spark context is created, related yourkit paths: https://screencast.com/t/tgFBYMEpW The problem is more general and is not related to HDFS in particular. Proper fix: register all cloned properties (in `localProperties#childValue`) in ConcurrentHashMap and forcefully clear all of them in `SparkContext#close` was: Memory leak is present due to inherited thread locals, SPARK-20558 didn't fixed it properly. Our production application has the following logic: one thread is reading from HDFS and another one creates spark context, processes HDFS files and then closes it on regular schedule. Depending on what thread started first, SparkContext thread local may or may not be inherited by HDFS-daemon (DataStreamer), causing memory leak when streamer was created after spark context. Memory consumption increases every time new spark context is created, related yourkit paths: https://screencast.com/t/tgFBYMEpW Proper fix: register all cloned properties (in `localProperties#childValue`) in ConcurrentHashMap and forcefully clear all of them in `SparkContext#close` > Properly cleanup inheritable thread-locals > ------------------------------------------ > > Key: SPARK-22625 > URL: https://issues.apache.org/jira/browse/SPARK-22625 > Project: Spark > Issue Type: Bug > Components: Spark Core > Affects Versions: 2.2.0 > Reporter: Tolstopyatov Vsevolod > Labels: leak > > Memory leak is present due to inherited thread locals, SPARK-20558 didn't fixed it properly. > Our production application has the following logic: one thread is reading from HDFS and another one creates spark context, processes HDFS files and then closes it on regular schedule. > Depending on what thread started first, SparkContext thread local may or may not be inherited by HDFS-daemon (DataStreamer), causing memory leak when streamer was created after spark context. Memory consumption increases every time new spark context is created, related yourkit paths: https://screencast.com/t/tgFBYMEpW > The problem is more general and is not related to HDFS in particular. > Proper fix: register all cloned properties (in `localProperties#childValue`) in ConcurrentHashMap and forcefully clear all of them in `SparkContext#close` -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org