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 7CC00200C09 for ; Wed, 25 Jan 2017 22:33:56 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7B5DF160B4E; Wed, 25 Jan 2017 21:33:56 +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 911D2160B3D for ; Wed, 25 Jan 2017 22:33:55 +0100 (CET) Received: (qmail 94531 invoked by uid 500); 25 Jan 2017 21:33:54 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 94519 invoked by uid 99); 25 Jan 2017 21:33:54 -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; Wed, 25 Jan 2017 21:33:54 +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 C72711A0247 for ; Wed, 25 Jan 2017 21:33:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.479 X-Spam-Level: ** X-Spam-Status: No, score=2.479 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=cloudera-com.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id vcDnuDpwHkHC for ; Wed, 25 Jan 2017 21:33:49 +0000 (UTC) Received: from mail-vk0-f49.google.com (mail-vk0-f49.google.com [209.85.213.49]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 9A3AE5F201 for ; Wed, 25 Jan 2017 21:33:49 +0000 (UTC) Received: by mail-vk0-f49.google.com with SMTP id k127so142633293vke.0 for ; Wed, 25 Jan 2017 13:33:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudera-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=q37850bY/hcyiAzU+8gLbyVgUVVOkZNKlVkwCzTdLtA=; b=P1ezVtRE5ZQdNCBUMvAykWf90Aj3V+SyaJGaFsVAowsWyNMQeVc/mFdd5hNUjZnpKh jFyCxqjhnp/VsD9iZAqB+lbCzra+sX1IJnKUVjgJo6ytFFUXAsURPl85IWHeJpriVl2A 81tGe4LxkhFofgyeNtnO2+DezgZc7LUoqEHJ4eAoiWrCzdS+1UzddXM5VXae/WeJ6gva gE1QTn6TIzlpUXcQPGCal45T7SKV3CdCZhBOYs8bt6cG4ausVu2Y1ABk+pSisYhjwgKO 9tKLRgKbusPaS3MXbUQlmOZZJhyeeD20xLAprcg5LophhhCpVglPsVL7rFLaf3XnblDi XxHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=q37850bY/hcyiAzU+8gLbyVgUVVOkZNKlVkwCzTdLtA=; b=DIgPGPFjcZPbY+V4D1MvvjBYVG8Tgmq4hPkuIKHe/zIqqzfR6i4MBU7dPsvDPiPde7 xz+DlUYTOzsOpVE1pBMWv5WdP3QKyN1RWBFnoqnyA/xy2K4LmibZaDhZ5SQURJDzFbC3 C6RREOJjaZ8gXyXt7CYcxxTdg0Qv34pRhGUGF82FlcJPJYONkck9BXms1g6VUSaO/HC8 fiaWgpM8f6BZMQbhW16K/u/ofUbrfeIjbTiSDsziO149xovK9aQr2i2FrRvZHxFPVrYq DS4VET9SEi/RSu73Z34U/NNplMvz6xh8lrOTHx5ht1cFminB47hpTaSSLbQniar5TM8+ QhPQ== X-Gm-Message-State: AIkVDXL1i1yIdDmJaQLsP+tEbVjiGfE4XNHHEJS7r8Ihs62yHfYlYhSNjst4SjnlGXuVKH30pr3U8TjuHD+ncYlw X-Received: by 10.31.196.194 with SMTP id u185mr8453616vkf.71.1485380028965; Wed, 25 Jan 2017 13:33:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.5.170 with HTTP; Wed, 25 Jan 2017 13:33:18 -0800 (PST) In-Reply-To: References: From: Michael Han Date: Wed, 25 Jan 2017 13:33:18 -0800 Message-ID: Subject: Re: are ephemeral nodes removed when client receives session expiration To: UserZooKeeper Content-Type: multipart/alternative; boundary=001a114e665efbbf860546f1fca0 archived-at: Wed, 25 Jan 2017 21:33:56 -0000 --001a114e665efbbf860546f1fca0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable >> Does ZK guarantee that ephemeral nodes from a client are removed on the sever by the time the client receives a session expiration event? "the server" is a vague definition, as ZooKeeper ensemble is composed of multiple servers :). >> Therefore, it seems to be possible for a client to connect to another server to see the node there. This seems the only case I can think of that lead to the inconsistent view from client side. I'll elaborate as follows, first the guarantees of ZooKeeper that's relevant to this case: * ZooKeeper quorum should have already committed the transaction of closing the session when a client receives the session expire event. * Clean up of ephemeral nodes associated with the session is part of the closing session transaction, so for the quorum of servers who have already committed the transaction, the ephemeral nodes should have gone already, on those servers. * ZooKeeper quorum would not have processed the new session establishment request for the same client, until after the closing session request has been processed because transactions are ordered across quorum. Given these guarantees, if a client reestablishes a new session via connecting to a server which was the quorum of servers that committed the closing session transaction, then the client should not see the old ephemeral node upon new session established. ZooKeeper does not guarantee a write transaction occur synchronously across all of the servers, since a write request only requires a quorum of servers to acknowledge. As a result, it is valid that some servers might lag behind the state of the quorum. I suspect this case is possible: * Client receives session expire event, and client close its connection to server A. * Client reconnects to server B, which lags behind quorum, that does not contain the changes to the data tree regarding ephemeral nodes. * Client sees the ephemeral node so it does nothing. Later the node is cleaned up when server B sync with quorum. Client can ensure it always see the state of truth of the quorum by issuing a sync() request before issuing a read request. A sync request will force the server it's connecting to sync with the quorum. If Kafka does this, will the bug go away? Of course, retry creating ephemeral nodes can also solve the problem (there are possible other solutions as well, by having client to do some book keeping work to differentiate versions between ephemeral nodes). On Wed, Jan 25, 2017 at 11:32 AM, Ryan Zhang wrote: > Good question, AFAIK, it=E2=80=99s not the case. > > The server will throw an SessionExpiredException during checkSession call > as soon as the session is marked as isClosing. However, session expiratio= n > actually requires a transaction (of type OpCode.closeSession) which will = be > send to the leader to go through the quorum. The session and ephemeral > node will only be removed after the transaction is committed and process= ed > in the final processor on other nodes. Therefore, it seems to be possible > for a client to connect to another server to see the node there. I am not > entirely sure if it can use the same session id though, it seems possible > as the session close is only based on the session expire time and there c= an > be delays in session pings. > > On Jan 25, 2017, at 8:53 AM, Jun Rao o@gmail.com>> wrote: > > Hi, > > Does ZK guarantee that ephemeral nodes from a client are removed on the > sever by the time the client receives a session expiration event? I am > getting conflicting info on this ( > https://issues.apache.org/jira/browse/KAFKA-4277). Could someone clarify? > > Thanks, > > Jun > > --=20 Cheers Michael. --001a114e665efbbf860546f1fca0--