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 6E743200C35 for ; Sun, 12 Mar 2017 20:39:09 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6D185160B77; Sun, 12 Mar 2017 19:39:09 +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 9199A160B69 for ; Sun, 12 Mar 2017 20:39:08 +0100 (CET) Received: (qmail 52850 invoked by uid 500); 12 Mar 2017 19:39:07 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 52839 invoked by uid 99); 12 Mar 2017 19:39:07 -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; Sun, 12 Mar 2017 19:39:07 +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 29686182319 for ; Sun, 12 Mar 2017 19:39:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.451 X-Spam-Level: * X-Spam-Status: No, score=1.451 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] 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 erHTo3XwstyP for ; Sun, 12 Mar 2017 19:39:05 +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 43A2560E08 for ; Sun, 12 Mar 2017 19:39:05 +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 B3F48E087E for ; Sun, 12 Mar 2017 19:39:04 +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 70E28243AC for ; Sun, 12 Mar 2017 19:39:04 +0000 (UTC) Date: Sun, 12 Mar 2017 19:39:04 +0000 (UTC) From: "Manjunath Anand (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (HADOOP-13726) Enforce that FileSystem initializes only a single instance of the requested FileSystem. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 12 Mar 2017 19:39:09 -0000 [ https://issues.apache.org/jira/browse/HADOOP-13726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15906663#comment-15906663 ] Manjunath Anand edited comment on HADOOP-13726 at 3/12/17 7:38 PM: ------------------------------------------------------------------- Thanks [~cnauroth] for your inputs. After looking at the points you raised I tried few sample code to understand more about {{computeIfAbsent}} and am presenting my observations below (please refer to the code I shared in my above comment):- 1) I could see that if the hashcode is same for say two similar keys which are passed to computeIfAbsent concurrently then one of them waits for the other to complete, but if the hashcode of the keys are different then it doesnt block each other. 2) Inference from test results of above point is that the below point you raised should be handled fairly well by the {{computeIfAbsent}} {quote} then only threads attempting to access s3a://my-bucket get blocked. Threads accessing a different FileSystem, such as hdfs://mylocalcluster can still make progress.{quote} I observed a benefit of using {{computeIfAbsent}} after referring to your point which am quoting below:- {quote}FileSystem initialization is neither short nor simple, involving things like network connections and authentication, all of which can suffer problematic failure modes like timeouts. {quote} What I observed during testing is that say if multiple threads try to create {{FileSystem}} for the same key and if one thread fails then by using the {{computeIfAbsent}} the next thread which was waiting will compute and I observed that this happens until the key has a non null value in the map. So in case of a timeout for first thread attempt to create a filesystem then either the second concurrent thread or any subsequent thread will be able to retry and see if it succeeds. I tried evaluating the suggestion of using {{LoadingCache/CacheLoader}} however I came across a problem where in for the overloaded {code}load(K key){code} how do we pass the URI and conf from the getInternal method , reason being the value for the map in getInternal method is not computed based on the Key but based on the URI and conf. There may be a workaround for this but it may involve more code change and redesign is my understanding. I am hoping I didnot miss out anything here but if I did please suggest. I would like to work on this JIRA (if you dont mind) but only after you are fine with the above observations and suggest me which approach to go ahead with or if you have any observations which I can explore further. was (Author: manju_hadoop): Thanks [~cnauroth] for your inputs. After looking at the points you raised I tried few sample code to understand more about {{computeIfAbsent}} and am presenting my observations below (please refer to the code I shared in my above comment):- 1) I could see that if the hashcode is same for say two similar keys which are passed to computeIfAbsent concurrently then one of them waits for the other to complete, but if the hashcode of the keys are different then it doesnt block each other. 2) Inference from test results of above point is that the below point you raised should be handled fairly well by the {{computeIfAbsent}} {quote} then only threads attempting to access s3a://my-bucket get blocked. Threads accessing a different FileSystem, such as hdfs://mylocalcluster can still make progress.{quote} I observed a benefit of using {{computeIfAbsent}} after referring to your point which am quoting below:- {quote}FileSystem initialization is neither short nor simple, involving things like network connections and authentication, all of which can suffer problematic failure modes like timeouts. {quote} What I observed during testing is that say if multiple threads try to create {{FileSystem}} for the same key and if one thread fails then by using the {{computeIfAbsent}} the next thread which was waiting will compute and I observed that this happens until the key has a non null value in the map. So in case of a timeout for first thread attempt to create a filesystem then either the second concurrent thread or any subsequent thread will be able to retry and see if it succeeds. I tried evaluating the suggestion of using {{LoadingCache/CacheLoader}} however I came across a problem where in for the overloaded {code}load(K key){code} how do we pass the URI and conf from the getInternal method , reason being the value for the map in getInternal method is not computed based on the Key but based on the URI and conf. There may be a workaround for this but it may involve more code change and redesign is my understanding. I am hoping I didnot miss out anything here but if I did please suggest. I would like to work on this (if you dont mind) but only after you are fine with the above observations and suggest me which approach to go ahead with or if you have any observations which I can explore further. > Enforce that FileSystem initializes only a single instance of the requested FileSystem. > --------------------------------------------------------------------------------------- > > Key: HADOOP-13726 > URL: https://issues.apache.org/jira/browse/HADOOP-13726 > Project: Hadoop Common > Issue Type: Improvement > Components: fs > Reporter: Chris Nauroth > > The {{FileSystem}} cache is intended to guarantee reuse of instances by multiple call sites or multiple threads. The current implementation does provide this guarantee, but there is a brief race condition window during which multiple threads could perform redundant initialization. If the file system implementation has expensive initialization logic, then this is wasteful. This issue proposes to eliminate that race condition and guarantee initialization of only a single instance. -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-issues-help@hadoop.apache.org