From user-return-12157-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Tue Sep 24 18:04:17 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id B2DF7180644 for ; Tue, 24 Sep 2019 20:04:16 +0200 (CEST) Received: (qmail 98672 invoked by uid 500); 24 Sep 2019 18:04:15 -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 98660 invoked by uid 99); 24 Sep 2019 18:04:15 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2019 18:04:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C7685C25F3 for ; Tue, 24 Sep 2019 18:04:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.052 X-Spam-Level: ** X-Spam-Status: No, score=2.052 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-ec2-va.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ypqNu-tr9O3G for ; Tue, 24 Sep 2019 18:04:12 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.214.174; helo=mail-pl1-f174.google.com; envelope-from=wander4096@gmail.com; receiver= Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mx1-ec2-va.apache.org (ASF Mail Server at mx1-ec2-va.apache.org) with ESMTPS id 24603BC50A for ; Tue, 24 Sep 2019 18:04:12 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id d22so1312081pll.7 for ; Tue, 24 Sep 2019 11:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=dvpGr1qmB+1StcGrB22plEQajxcyjeToUerADKrAg3U=; b=B+GrIE98uP105wHgk0/lhhL66ZaCJoIDbqIH3FrNSGHqvh0zgGwLWUH+ZzDDkTXqnc sE6MqeasmdhVW6LFBmeq/h0glFD/GOeAZBW0zsdAaUbWUgXwYdIYsCK4jdheNqoNtXPA 7T/OxVv89g7EHqpAKUYj0scbvUasPUMwP+OoqE0NED3qUwkT5/F+QTi35fIu3rp7xp/P Uby8eqcu44XEeflSfgWxnv2SKFiY6TqzzDkyPAAl97hH1pXU3jFJ+yQdl5pN61ueb3NK Cd33W9CpjjUhkxZv7lgaVYQUNk61AbGoojYbJq3jrPtUz/raX8twhttpyr0FSMjOdM0u mrRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=dvpGr1qmB+1StcGrB22plEQajxcyjeToUerADKrAg3U=; b=jj02yRKrTgeiUtVLzxUChtKmtq6BqzORIf+to0w46cwYbLldWPdDMqxlrTES+clRJ+ tfA4tnYQeNXRdMZD+H0TJzi8xduiWpU9OiBMimeqwvY0Df1sGxRMznK6CVDyW6d5R2ri VrVJh21naZfsNZiqGxNxd6Arjia8ab/KDLR/DCqfq6OGSx64kVsnR1YWdwc7lws1euHS i5sav7H+YPdIiRL9YtZn5TmbiCD+1M45QrFzbJlE14oaphd/EdoHik82UfN6O6iJxIKo EWArITdcPmyMHGek56e6Z7NIYCXgOMHU+bsjZFb6nyrGaRMhfqGP8sbztKDJsG2OsYnl DA8Q== X-Gm-Message-State: APjAAAVfiySsxtgtIos+1RTWe3PwfEQ6QbccaAo9vII3+9Rp+4UIVBTd noEEdHEOlk64ZCdw7/QPR6SVRhjT0eqJjJyBkhqbgj9nWfUXrw== X-Google-Smtp-Source: APXvYqzYudUZwXLxmDtv5Ksvqq7bYRv9meEEqgMP+T1YSAhcGa+wx3VnFHvXJ7TMe7/sN4t9AEsw6W9bFeoHxNZB5LI= X-Received: by 2002:a17:902:8649:: with SMTP id y9mr4008827plt.252.1569348244776; Tue, 24 Sep 2019 11:04:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zili Chen Date: Wed, 25 Sep 2019 02:03:28 +0800 Message-ID: Subject: Re: how session expire works in zookeeper codebase? To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary="000000000000a8ab8d0593505c37" --000000000000a8ab8d0593505c37 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Enrico, Well I think I understand how it works now and why you said it is a weird edge case >if the server/cluster is down the session cannot expire. If the server find a session expire, it will close the socket and the client will try to reconnect to the ensemble. While it successfully reconnects to one of the ensemble it will find session expire... You're right that if we lost connection to all the ensemble we cannot even notice that we are in session expired state. And I think it is the reason why Curator also check if time has already elapsed over session timeout. Best, tison. Zili Chen =E4=BA=8E2019=E5=B9=B49=E6=9C=8824=E6=97= =A5=E5=91=A8=E4=BA=8C =E4=B8=8B=E5=8D=888:20=E5=86=99=E9=81=93=EF=BC=9A > Enrico, > > Thanks for your reply. > > Still I cannot understand how session expire detected on client side. The > only codepath > KeeperState.Expired generated is ClientCnxn#onConnected. It seems only > called on > client successfully connected to server. However, session could expire > after connection > established. Where is the latter case trigger? > > Best, > tison. > > > Enrico Olivelli =E4=BA=8E2019=E5=B9=B49=E6=9C=8824= =E6=97=A5=E5=91=A8=E4=BA=8C =E4=B8=8B=E5=8D=888:06=E5=86=99=E9=81=93=EF=BC= =9A > >> Zili, >> Sessions expire in the server. If you are not connected to the cluster y= ou >> cannot assume that the session is expired. >> >> There is another weird edge case: if the server/cluster is down the >> session >> cannot expire. >> >> Hope that helps >> Enrico >> >> Il mar 24 set 2019, 13:54 Zili Chen ha scritto: >> >> > Hi ZooKeepers, >> > >> > I want to trace where Watcher.Event.KeeperState.Expired generated and = it >> > seems only generated >> > when connect to server fails due to exceed session timeout. >> > >> > Besides, I find code snippet in ClientCnxn as below >> > >> > void queueEvent(String clientPath, int err, Set >> > materializedWatchers, EventType eventType) { >> > KeeperState sessionState =3D KeeperState.SyncConnected; >> > if (KeeperException.Code.SESSIONEXPIRED.intValue() =3D=3D err >> > || KeeperException.Code.CONNECTIONLOSS.intValue() =3D=3D e= rr) { >> > sessionState =3D Event.KeeperState.Disconnected; >> > } >> > WatchedEvent event =3D new WatchedEvent(eventType, sessionStat= e, >> > clientPath); >> > eventThread.queueEvent(event, materializedWatchers); >> > } >> > >> > which seems a bit wried to me what we queue >> > a Event.KeeperState.Disconnected on >> > KeeperException.Code.SESSIONEXPIRED. >> > >> > Back to the question, how zookeeper discovers and triggers session >> expire >> > event on >> > session expired after connection established successfully? >> > >> > Best, >> > tison. >> > >> > --000000000000a8ab8d0593505c37--