Return-Path: X-Original-To: apmail-curator-dev-archive@minotaur.apache.org Delivered-To: apmail-curator-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 814721883C for ; Fri, 5 Feb 2016 17:26:12 +0000 (UTC) Received: (qmail 39430 invoked by uid 500); 5 Feb 2016 17:26:12 -0000 Delivered-To: apmail-curator-dev-archive@curator.apache.org Received: (qmail 39384 invoked by uid 500); 5 Feb 2016 17:26:12 -0000 Mailing-List: contact dev-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list dev@curator.apache.org Received: (qmail 39371 invoked by uid 99); 5 Feb 2016 17:26:11 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2016 17:26:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 87A56C0D58 for ; Fri, 5 Feb 2016 17:26:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.28 X-Spam-Level: * X-Spam-Status: No, score=1.28 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=jordanzimmerman-com.20150623.gappssmtp.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id H6Q7nG5piWC7 for ; Fri, 5 Feb 2016 17:26:09 +0000 (UTC) Received: from mail-ig0-f181.google.com (mail-ig0-f181.google.com [209.85.213.181]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 331B8439ED for ; Fri, 5 Feb 2016 17:26:09 +0000 (UTC) Received: by mail-ig0-f181.google.com with SMTP id mw1so18323452igb.1 for ; Fri, 05 Feb 2016 09:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jordanzimmerman-com.20150623.gappssmtp.com; s=20150623; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=JWoyP+MnOljc9agPZGFUEtpvZzAak316ZJ7tHwrC6gc=; b=EJNcf3kzQ11zKIvnahXcqEal0tCAtdxHKsUAEIy0mq/nmgA8F7q5ihkFoIpUNLZHgt yCR/Rgd1qBxQcWFjWscRQ9U3vHCsUIRGs6FqGS6yWC9xb6bTtxSHsHX7G4zq8buYHBbg igxg8mwT4k6ERyGjfqDmUkzCmDRxciYG0K+81iX4J/ahGhD6GS4pjdWCv2CG9w2/K+lO rZnGmdi9mX5lsYRQCsVDFiF7lTv/a0wwifq9LSL3zh6aYWaLSxcpNm7ieb2h4jp9G7Rl Vb0dmjkGDV+vaP4tZhAZtiC4AMUC2/VQzuavcjsvnbewjCJ1KqU0/j/0PECxmp65BiY+ g+/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=JWoyP+MnOljc9agPZGFUEtpvZzAak316ZJ7tHwrC6gc=; b=GzMOBHVj9jPML13HLfVhuK6QPtiBqcDBNBE3vpGamXyCllLPFx4dhSX8/YJqwmDSWD X8VsNr60HJZUzgob2pYClxllAqKOwNwZRvkBQVeaBx/NDhVcMKny7J2RF00cs+Zz78nm ssHlf5jQ/iW4ZuVOgD9rUCQ65rT7+1eL+b6IL3WnD+PLsw0OscG4PzXpIfGM6I36VOtC ALkJ8ahdq/eine7QNvKARh1PqxTxJuosx73Ot6SQYxkhAIAJufRJWowtPwD/7+jTrNQA LZqn1ZjbL4zd+m7ZNhCX8NGUHTzQjQ+DXnrd41m64zxQbWeO9ZiD+5K9CYuFZesjkmqD Fh3Q== X-Gm-Message-State: AG10YOSqSMdK0mdh5+5r7TjPFPGHtFF2o864RxK3GqKNyEth5HwNgE1qE4d01xsjbVOxVg== X-Received: by 10.51.17.39 with SMTP id gb7mr16255170igd.29.1454693161813; Fri, 05 Feb 2016 09:26:01 -0800 (PST) Received: from [10.0.1.67] ([186.188.195.79]) by smtp.gmail.com with ESMTPSA id 90sm4291313iod.12.2016.02.05.09.25.59 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Feb 2016 09:26:00 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_D5B2C75C-2B33-4C7E-85A3-859D53374687" Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Subject: Re: PLEASE REVIEW - Major re-work of Watcher wrappers From: Jordan Zimmerman In-Reply-To: Date: Fri, 5 Feb 2016 12:25:57 -0500 Cc: "dev@curator.apache.org" Message-Id: <8E4199BD-6975-4CF3-90BB-16F05FB71342@jordanzimmerman.com> References: <12BFA12E-B07C-4CDD-AD15-7019C8102DB5@jordanzimmerman.com> <389A2290-081C-4B21-8B4F-DE32DA01249A@jordanzimmerman.com> To: Scott Blum X-Mailer: Apple Mail (2.3112) --Apple-Mail=_D5B2C75C-2B33-4C7E-85A3-859D53374687 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 OK - please create a new Issue in Jira for this. -Jordan > On Feb 5, 2016, at 12:24 PM, Scott Blum wrote: >=20 > BTW: this is broken on CURATOR-3.0 as well, so it appears to have been = broken for a while. Maybe I'll have to git bisect... >=20 > On Fri, Feb 5, 2016 at 12:22 PM, Scott Blum > wrote: > Okay, so I looked into this for a bit, and I hit kind of a wall. I = think there is a legit bug/race in TreeCache, and the following patch = *should* remedy: >=20 > diff --git = a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache= /TreeCache.java = b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache= /TreeCache.java > index df4403c..a4a022b 100644 > --- = a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache= /TreeCache.java > +++ = b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache= /TreeCache.java > @@ -303,7 +303,6 @@ public class TreeCache implements Closeable > void wasDeleted() throws Exception > { > ChildData oldChildData =3D childData.getAndSet(null); > - = client.watches().remove(this).ofType(WatcherType.Any).locally().inBackgrou= nd().forPath(path); > ConcurrentMap childMap =3D = children.getAndSet(null); > if ( childMap !=3D null ) > { > @@ -807,8 +806,16 @@ public class TreeCache implements Closeable > case RECONNECTED: > try > { > + outstandingOps.incrementAndGet(); > root.wasReconnected(); > = publishEvent(TreeCacheEvent.Type.CONNECTION_RECONNECTED); > + if ( outstandingOps.decrementAndGet() =3D=3D 0 ) > + { > + if ( isInitialized.compareAndSet(false, true) ) > + { > + = publishEvent(TreeCacheEvent.Type.INITIALIZED); > + } > + } > } > catch ( Exception e ) > { >=20 > That should guarantee that the initialized event gets deferred until = all outstanding refreshes finish.. but it's not. Something seems to = have changed under the hood in how background events are getting sent to = TreeCache, and I don't really understand it yet. And running the = debugger seems to affect the timing, like something racy is going on. :( >=20 >=20 > On Fri, Feb 5, 2016 at 11:57 AM, Scott Blum > wrote: > Ok, that is kind of weird. I'll take a look. >=20 > On Fri, Feb 5, 2016 at 4:58 AM, Jordan Zimmerman = > wrote: > No, sorry. The last few lines of the test currently are: >=20 > assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", = "data".getBytes()); > assertEvent(TreeCacheEvent.Type.INITIALIZED); >=20 > This fails. But, if I switch them it works: >=20 > assertEvent(TreeCacheEvent.Type.INITIALIZED); > assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", = "data".getBytes()); >=20 >> On Feb 5, 2016, at 2:57 AM, Scott Blum > wrote: >>=20 >> So you end up with 2 initialized events? >>=20 >> You mean this? >>=20 >> assertEvent(TreeCacheEvent.Type.CONNECTION_RECONNECTED); >> + assertEvent(TreeCacheEvent.Type.INITIALIZED); >> assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", = "data".getBytes()); >> assertEvent(TreeCacheEvent.Type.INITIALIZED); >>=20 >> Seems weird if there are two, but I can help look. >>=20 >> On Thu, Feb 4, 2016 at 10:48 PM, Jordan Zimmerman = > wrote: >> Hey Scott, >>=20 >> In this branch, TestTreeCache.testKilledSession() is failing at: >>=20 >> assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", = "data".getBytes()); >>=20 >> However, if I change the two asserts to: >>=20 >> assertEvent(TreeCacheEvent.Type.INITIALIZED); >> assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", = "data".getBytes()); >>=20 >> it works. Does that make any sense? >>=20 >> -Jordan >>=20 >> > On Feb 4, 2016, at 9:23 PM, Jordan Zimmerman = > wrote: >> > >> > Devs, >> > >> > In trying to fix the bad log message "Failed to find watcher=E2=80=9D= (which turns out to be a ZK client issue), I realize that the = NamespaceWatcher and WatcherWrapper stuff could be improved. I=E2=80=99m = still working on getting all tests to pass but I=E2=80=99d appreciate = more sets of eyes on this change. Please review carefully if you can. >> > >> > https://github.com/apache/curator/pull/131 = >> > >> > -Jordan >>=20 >>=20 >=20 >=20 >=20 >=20 --Apple-Mail=_D5B2C75C-2B33-4C7E-85A3-859D53374687--