Return-Path: X-Original-To: apmail-accumulo-dev-archive@www.apache.org Delivered-To: apmail-accumulo-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 26CDE10006 for ; Fri, 27 Dec 2013 23:52:40 +0000 (UTC) Received: (qmail 87615 invoked by uid 500); 27 Dec 2013 23:52:40 -0000 Delivered-To: apmail-accumulo-dev-archive@accumulo.apache.org Received: (qmail 87526 invoked by uid 500); 27 Dec 2013 23:52:40 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 87518 invoked by uid 99); 27 Dec 2013 23:52:40 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Dec 2013 23:52:40 +0000 Received: from localhost (HELO mail-lb0-f174.google.com) (127.0.0.1) (smtp-auth username ctubbsii, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Dec 2013 23:52:39 +0000 Received: by mail-lb0-f174.google.com with SMTP id y6so4469178lbh.5 for ; Fri, 27 Dec 2013 15:52:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=MzdnSpx2GyDce8rxHPsU9SA2j3a+wieAZVI1WvBO+Ls=; b=ZTSYCvvPFJGL/SQ+InmLFbTBUregfPJQBdBwUUNOc0wM91bglGGeyn5ZdJ6FPxnCd8 4GdUPyQ8E0Cn8OemXgHMfJUmt46vsn77PTSNQQVuByuvKFRrZWWUw4VdwWDEX7ZYrQhX p5ta/MzQCuzOxQbd+8W4IL0Cd/laoPs/hMcPLZieEljGkuXu8RHNTM2WX24h9oCnBER9 oKy+LWJA0LsD73jWZCy+BrjDPni8z3OvO/p8rlPQad5osg2uD1DDyzyN2GZOol7pkp9K P5NrXV3/r0GJmF2iqaVMQCiG4nMWO6LiG+iJk7fBry5sRqynnq4wxejzq1AHmW/0cS7X IcPA== MIME-Version: 1.0 X-Received: by 10.112.141.166 with SMTP id rp6mr6820835lbb.39.1388188357807; Fri, 27 Dec 2013 15:52:37 -0800 (PST) Received: by 10.114.18.228 with HTTP; Fri, 27 Dec 2013 15:52:37 -0800 (PST) In-Reply-To: References: Date: Fri, 27 Dec 2013 18:52:37 -0500 Message-ID: Subject: Re: Resource leak warnings From: Christopher To: Accumulo Dev List Content-Type: text/plain; charset=UTF-8 The javadoc for Instance says: "This class represents the information a client needs to know to connect to an instance of accumulo." There's no mention of connection resources or shared state, or any indication that it is used for anything other than a one-time method to get a connection... it seems to be defined as configuration information. The fact that we're talking about it representing connection resources (which aren't even stored in ZooKeeperInstance itself, but happens to use some of the shared state we're talking about for its own implementation), is a bit confusing in the context of the declared semantics from the javadoc. The fact is, we store state statically, as global resources, in the JVM, and (I think) changing the definition of Instance to represent this statically stored state, is very confusing. I think a static utility makes a lot more sense to clean up static shared state hidden deep in the implementation... until we can invent (in a new API) an actual ConnectionResources object to represent connection resources, with a well-defined lifetime (not "for the duration of the JVM's lifetime", as it currently is defined in released versions) where the cleanup of these resources makes sense. -- Christopher L Tubbs II http://gravatar.com/ctubbsii On Fri, Dec 27, 2013 at 2:23 PM, William Slacum wrote: > We need to actually define the usage pattern and lifetime of a > ZooKeeperInstance. Looking at the code, it's really masking a singleton > usage pattern. The resources backing a given set of zookeepers+timeout pair > all share a ZooCache, and we hand-rolled reference counting for > ZooKeeperInstances themselves. That indicates that a ZooKeeperInstance is > basically a global variable, and we have to be careful about the resources > it allocates, directly or indirectly, because their lifetimes are opaque > from the perspective of the client. > > I'm a fan of the close method, because it puts, in code, how an instance > tidies up after itself. We didn't have any cleanup before because the > ZooCache for a given zookeeper+timeout lived on until the process died. > Since the side effects of our API aren't documented or made clear to the > client, it's on us to handle and manage them. Making it optional for a user > is a benefit, because maybe they don't care and someone else (gc, another > management thread) will call close() on the instance, or maybe they want to > force a close at class unloading. > > The utility seems to be brute forcing shutdown- is it possible to get > something finer grained for specific instances? Shutting down every thing > will handle the "clean up at unload" time issue, but not necessarily > anything involving closing down a subset of ZooSessions. > > > > On Thu, Dec 26, 2013 at 2:48 PM, Sean Busbey wrote: > >> On Dec 26, 2013 12:27 PM, "Mike Drob" wrote: >> > >> > I'm willing to stipulate that this solves the thread leak from web >> > containers - I haven't verified it, but I am ever hopeful. Does this >> > solution imply that we should nix the close() methods just added in the >> > snapshot branches? >> > >> > >> >> If we can verify that it solves the leaks for web containers, I would say >> yes. >> >> We can do proper life cycle for persistent state when we provide an updated >> client API. >>