From user-return-12254-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Sun Oct 27 23:50:58 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 481F1180630 for ; Mon, 28 Oct 2019 00:50:58 +0100 (CET) Received: (qmail 25891 invoked by uid 500); 27 Oct 2019 23:50:56 -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 25879 invoked by uid 99); 27 Oct 2019 23:50:56 -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; Sun, 27 Oct 2019 23:50:56 +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 D4F9E1A4191 for ; Sun, 27 Oct 2019 23:50:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 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, HTML_MESSAGE=0.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id fxVgW0WifUTH for ; Sun, 27 Oct 2019 23:50:54 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::b2e; helo=mail-yb1-xb2e.google.com; envelope-from=shayshim@gmail.com; receiver= Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id D5FD47E1B5 for ; Sun, 27 Oct 2019 23:40:32 +0000 (UTC) Received: by mail-yb1-xb2e.google.com with SMTP id w5so3209293ybs.11 for ; Sun, 27 Oct 2019 16:40:32 -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=IPXnmBcLKkvh1pkVFqpjwDoYtaVQr+IEiPpFdSjBbTc=; b=CStGS++fMcDzyejbsW0wmPEaNuI0AzWJUwR5gKzDthujMri/pHcyNict15xqIODEjm SFF+QD506pB/ARrc/1FaTVksG2XG044SHbuJwNEGQD3VMVa1tcRjwfZgAYxrJun7Cido CGr3UjK/1WyP4Redb824TBILDZE5GSZFQceJZOZFRjTDK0pPkuSLzimsXV/yW0FybpqT I1adYRqW2rqHjCmVnrrbrHBA9eZCKmnLhhClMOiUc5feTpUxFZDdAL06wGqdgR/4si1h zUlb9ej11K1yGgFCV2oa3XFk06DWs8Z1yawluTW8U/JogWdXtuZcUg1ncOpG5hrzS6LS To3A== 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=IPXnmBcLKkvh1pkVFqpjwDoYtaVQr+IEiPpFdSjBbTc=; b=fv7g65UDw4pcnyyYw8J1tkIGdoHbq3mF9/KVXBLOqOv8CVWel0OBPQosNsogZfoh7N Yrjk46vtv1kRuQecf/XrP+HSAAWRP8L6UVYcxnMqtBnknVxLCfeAru3QwoGGYw9WhHnj W1lnIa9FpldWqMrGPlw56YaTz0hftBgC2hBPkT2e0p+3bWtyIQWbprqYIS7SC2+2HIDe 3QHYEQuNo3gjQgH3z4HO247ng52mi1hjXnHjUTykOopx0Taj1RQcrz7RR608XnRZTUOz O+0Rs45ZWCopjWVySI3Do72bEmpD7LwxFgTSZJDH0X3cNpuL4UmmAUyaF9hYC+FzS2Lp QQ0w== X-Gm-Message-State: APjAAAXIRvJhFLxr0phXQ42OakLeINaJvk7+WgwHO2wNykpnIW0mInMU FEqnTHMIPhRA/H4E5dOMtgpc1cA2Y1VXqCVjNYI= X-Google-Smtp-Source: APXvYqy7jR4QrnTwU4bngJP5HNWBOX6YRs1mSibotkumhIbWW/Oz+XZkU968my5c2w1ti9lkmYWypeBJM2JTBp/OV2o= X-Received: by 2002:a25:4a43:: with SMTP id x64mr599610yba.37.1572219626158; Sun, 27 Oct 2019 16:40:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shay shimony Date: Mon, 28 Oct 2019 01:39:49 +0200 Message-ID: Subject: Re: ZooKeeper Leader Election Question To: Lee Eric , user@zookeeper.apache.org Content-Type: multipart/alternative; boundary="000000000000537fa00595ece8c8" --000000000000537fa00595ece8c8 Content-Type: text/plain; charset="UTF-8" Hi Eric, I checked the Leader Elections section in the ZooKeeper book of Junqueira and Reed, and found that you have a mistake in the rules that you quoted - the '>' sign should be '<': 1. If (voteZxid *<* myZxid) or (voteZxid = myZxid and voteId *<* mySid), keep the current vote. 2. Otherwise, change my vote by assigning myZxid to voteZxid and mySid to vote zxid. When z3 compares votes from z1(1, 6) and its current vote (3, 5), it changes its vote to (1, 6). Next, z3 compares (2, 5) and its current vote (1, 6), and keeps its current vote (1, 6). After these 2 iterations z3 will send again its vote to z1 and z2 - this time (1, 6). Next, z3 and z1 form a quorum of 2, with z1 as leader and z3 as its follower. Hopefully z2 will be on the same page, similarly will join the quorum, and set itself as follower of z1 as well (normally it will). Hope it helps, Shay On Sun, Oct 27, 2019 at 8:11 AM Lee Eric wrote: > Hi, > > I have a dumb question about the way how zookeeper does leader election. > > There is a quorum zk1(1,6), zk2(2,5) and zk3(3,5). The number in > parentheses is sid and latest zxid. So my question is, when each > server sends out the vote to other 2, say, zk1 and zk2 send the votes > to zk3. So zk3 has 2 votes (1,6) and (2,5). Now, based on the rules: > > 1. If (voteZxid > myZxid) or (voteZxid = myZxid and voteId > mySid), > keep the current vote. > 2. Otherwise, change my vote by assigning myZxid to voteZxid and mySid to > vote > Zxid. > > So what zk3 vote would be? I'm confused because to compare zk1 and > zk3, the vote on zk3 is (1,6); but to compare zk2 and zk3, zk3 should > keep its vote. > > So in this case, how the vote should be settled? > > Thanks. > > Eric > --000000000000537fa00595ece8c8--