From dev-return-72032-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Thu Aug 2 00:06:05 2018 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 [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0103F18067B for ; Thu, 2 Aug 2018 00:06:04 +0200 (CEST) Received: (qmail 30339 invoked by uid 500); 1 Aug 2018 22:06:04 -0000 Mailing-List: contact dev-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list dev@zookeeper.apache.org Received: (qmail 30326 invoked by uid 99); 1 Aug 2018 22:06:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Aug 2018 22:06:04 +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 89103C00B8 for ; Wed, 1 Aug 2018 22:06:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id fCOQy2rO-4ae for ; Wed, 1 Aug 2018 22:06:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 94A995F403 for ; Wed, 1 Aug 2018 22:06:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 035EEE25AA for ; Wed, 1 Aug 2018 22:06:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 4ABAC27768 for ; Wed, 1 Aug 2018 22:06:00 +0000 (UTC) Date: Wed, 1 Aug 2018 22:06:00 +0000 (UTC) From: "Fangmin Lv (JIRA)" To: dev@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (ZOOKEEPER-3109) Avoid long unavailable time due to voter changed mind when activating the leader during election MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ZOOKEEPER-3109?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fangmin Lv updated ZOOKEEPER-3109: ---------------------------------- Description:=20 Occasionally, we'll find it takes long time to elect a leader, might longer= then 1 minute, depends on how big the initLimit and tickTime are set. =C2=A0 This exposes an issue in leader election protocol. During leader election,= before the voter goes to the LEADING/FOLLOWING state, it will wait for a f= inalizeWait time before changing its state. Depends on the order of notific= ations, some voter might change mind just after it voting for a server. If = the server it was previous voting for has majority of votes after consideri= ng this one, then that server will goto LEADING state. In some corner cases= , the leader may end up with timeout waiting for epoch ACK from majority, b= ecause of the changed mind voter. This usually happen when there are even n= umber of servers in the ensemble (either because one of the server is down = or being restarted and it takes long time to restart). If there are 5 serve= rs in the ensemble, then we'll find two of them in LEADING/FOLLOWING state,= another two in LOOKING state, but the LOOKING servers cannot join the quor= um since they're waiting for majority servers FOLLOWING the current leader = before changing to FOLLOWING as well. =C2=A0 As far as we know, this voter will change mind if it received a vote from = another host which just started and start to vote itself, or there is a ser= ver takes long time to shutdown it's previous ZK server and start to vote i= tself when starting the leader election process. =C2=A0 Also the follower may abandon the leader if the leader is not ready for ac= cepting learner connection when the follower tried to connect to it. =C2=A0 To solve this issue, there are multiple options:=C2=A0 1. increase the finalizeWait time 2. smartly detect this state on leader and quit earlier =C2=A0 The 1st option is straightforward and easier to change, but it will cause = longer leader election time in common cases. =C2=A0 The 2nd option is more complexity, but it can efficiently solve the proble= m without sacrificing the performance in common cases. It remembers the fir= st majority servers voting for it, checking if there is anyone changed mind= while it's waiting for epoch ACK. The leader will wait for sometime before= quitting LEADING state, since one voter changed may not be a problem if th= ere are still majority voters voting for it. was: Occasionally, we'll find it takes long time to elect a leader, might longer= then 1 minute, depends on how big the initLimit and tickTime are set. =C2=A0 This exposes an issue in leader election protocol. During leader election, = before the voter goes to the LEADING/FOLLOWING state, it will wait for a fi= nalizeWait time before changing its state. Depends on the order of notifica= tions, some voter might change mind just after it voting for a server. If t= he server it was previous voting for has majority of votes after considerin= g this one, then that server will goto LEADING state. In some corner cases,= the leader may end up with timeout waiting for epoch ACK from majority, be= cause of the changed mind voter. This usually happen when there are even nu= mber of servers in the ensemble (either because one of the server is down o= r being restarted and it takes long time to restart). If there are 5 server= s in the ensemble, then we'll find two of them in LEADING/FOLLOWING state, = another two in LOOKING state, but the LOOKING servers cannot join the quoru= m since they're waiting for majority servers FOLLOWING the current leader b= efore changing to FOLLOWING as well. =C2=A0 As far as we know, this voter will change mind if it received a vote from a= nother host which just started and start to vote itself, or there is a serv= er takes long time to shutdown it's previous ZK server and start to vote it= self when starting the leader election process. =C2=A0 Also the follower may abandon the leader if the leader is not ready for acc= epting learner connection when the follower tried to connect to it. =C2=A0 To solve this issue, there are multiple options: #=20 increase the finalizeWait time #=20 smartly detect this state on leader and quit earlier =C2=A0 The 1st option is straightforward and easier to change, but it will cause l= onger leader election time in common cases. =C2=A0 The 2nd option is more complexity, but it can efficiently solve the problem= without sacrificing the performance in common cases. It remembers the firs= t majority servers voting for it, checking if there is anyone changed mind = while it's waiting for epoch ACK. The leader will wait for sometime before = quitting LEADING state, since one voter changed may not be a problem if the= re are still majority voters voting for it. > Avoid long unavailable time due to voter changed mind when activating the= leader during election > -------------------------------------------------------------------------= ----------------------- > > Key: ZOOKEEPER-3109 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3109 > Project: ZooKeeper > Issue Type: Improvement > Components: quorum, server > Affects Versions: 3.6.0 > Reporter: Fangmin Lv > Assignee: Fangmin Lv > Priority: Major > Fix For: 3.6.0 > > > Occasionally, we'll find it takes long time to elect a leader, might long= er then 1 minute, depends on how big the initLimit and tickTime are set. > =C2=A0 > This exposes an issue in leader election protocol. During leader electio= n, before the voter goes to the LEADING/FOLLOWING state, it will wait for a= finalizeWait time before changing its state. Depends on the order of notif= ications, some voter might change mind just after it voting for a server. I= f the server it was previous voting for has majority of votes after conside= ring this one, then that server will goto LEADING state. In some corner cas= es, the leader may end up with timeout waiting for epoch ACK from majority,= because of the changed mind voter. This usually happen when there are even= number of servers in the ensemble (either because one of the server is dow= n or being restarted and it takes long time to restart). If there are 5 ser= vers in the ensemble, then we'll find two of them in LEADING/FOLLOWING stat= e, another two in LOOKING state, but the LOOKING servers cannot join the qu= orum since they're waiting for majority servers FOLLOWING the current leade= r before changing to FOLLOWING as well. > =C2=A0 > As far as we know, this voter will change mind if it received a vote fro= m another host which just started and start to vote itself, or there is a s= erver takes long time to shutdown it's previous ZK server and start to vote= itself when starting the leader election process. > =C2=A0 > Also the follower may abandon the leader if the leader is not ready for = accepting learner connection when the follower tried to connect to it. > =C2=A0 > To solve this issue, there are multiple options:=C2=A0 > 1. increase the finalizeWait time > 2. smartly detect this state on leader and quit earlier > =C2=A0 > The 1st option is straightforward and easier to change, but it will caus= e longer leader election time in common cases. > =C2=A0 > The 2nd option is more complexity, but it can efficiently solve the prob= lem without sacrificing the performance in common cases. It remembers the f= irst majority servers voting for it, checking if there is anyone changed mi= nd while it's waiting for epoch ACK. The leader will wait for sometime befo= re quitting LEADING state, since one voter changed may not be a problem if = there are still majority voters voting for it. -- This message was sent by Atlassian JIRA (v7.6.3#76005)