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 07492200D2E for ; Tue, 31 Oct 2017 21:34:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 05EC71609EF; Tue, 31 Oct 2017 20:34:08 +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 2391D1609E6 for ; Tue, 31 Oct 2017 21:34:06 +0100 (CET) Received: (qmail 76756 invoked by uid 500); 31 Oct 2017 20:34:06 -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 76745 invoked by uid 99); 31 Oct 2017 20:34:06 -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, 31 Oct 2017 20:34:06 +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 6EB6FD2E5C for ; Tue, 31 Oct 2017 20:34:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id OW4nE5Ay94xU for ; Tue, 31 Oct 2017 20:34:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 0703D60F7B for ; Tue, 31 Oct 2017 20:34:03 +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 C9DBDE2656 for ; Tue, 31 Oct 2017 20:34: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 9E41021314 for ; Tue, 31 Oct 2017 20:34:00 +0000 (UTC) Date: Tue, 31 Oct 2017 20:34:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (ZOOKEEPER-2684) Fix a crashing bug in the mixed workloads commit processor MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 31 Oct 2017 20:34:08 -0000 [ https://issues.apache.org/jira/browse/ZOOKEEPER-2684?page=3Dcom.atlas= sian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D= 16227482#comment-16227482 ]=20 ASF GitHub Bot commented on ZOOKEEPER-2684: ------------------------------------------- Github user kfirlevari commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/411#discussion_r148119340 =20 --- Diff: src/java/main/org/apache/zookeeper/server/quorum/CommitProces= sor.java --- @@ -246,33 +246,51 @@ public void run() { } =20 /* - * Check if request is pending, if so, update it w= ith the - * committed info + * Check if request is pending, if so, update it w= ith the committed info */ LinkedList sessionQueue =3D pendingReques= ts .get(request.sessionId); if (sessionQueue !=3D null) { // If session queue !=3D null, then it is also= not empty. Request topPending =3D sessionQueue.poll(); if (request.cxid !=3D topPending.cxid) { - LOG.error( - "Got cxid 0x" - + Long.toHexString(request= .cxid) - + " expected 0x" + Long.to= HexString( - topPending.cxid) - + " for client session id " - + Long.toHexString(request.session= Id)); - throw new IOException("Error: unexpected c= xid for" - + "client session"); + // TL;DR - we should not encounter this sc= enario often under normal load. + // We pass the commit to the next processo= r and put the pending back with a warning. + + // Generally, we can get commit requests t= hat are not at the queue head after + // a session moved (see ZOOKEEPER-2684). L= et's denote the previous server of the session + // with A, and the server that the session= moved to with B (keep in mind that it is + // possible that the session already moved= from B to a new server C, and maybe C=3DA). + // 1. If request.cxid < topPending.cxid : = this means that the session requested this update + // from A, then moved to B (i.e., which is= us), and now B receives the commit + // for the update after the session alread= y performed several operations in B + // (and therefore its cxid is higher than = that old request). + // 2. If request.cxid > topPending.cxid : = this means that the session requested an updated + // from B with cxid that is bigger than th= e one we know therefore in this case we + // are A, and we lost the connection to th= e session. Given that we are waiting for a commit + // for that update, it means that we alrea= dy sent the request to the leader and it will + // be committed at some point (in this cas= e the order of cxid won't follow zxid, since zxid + // is an increasing order). It is not safe= for us to delete the session's queue at this + // point, since it is possible that the se= ssion has newer requests in it after it moved + // back to us. We just leave the queue as = it is, and once the commit arrives (for the old + // request), the finalRequestProcessor wil= l see a closed cnxn handle, and just won't send a + // response. + // Also note that we don't have a local se= ssion, therefore we treat the request + // like any other commit for a remote requ= est, i.e., we perform the update without sending + // a response. + + LOG.warn("Got request " + request + + " but we are expecting request " += topPending); + sessionQueue.addFirst(topPending); + } else { + // We want to send to the next processor o= ur version of the request, + // since it contains the session informati= on that is needed + // for post update processing (e.g., using= request.cnxn we send a response to the client). + topPending.setHdr(request.getHdr()); --- End diff -- =20 Updated accordingly > Fix a crashing bug in the mixed workloads commit processor > ---------------------------------------------------------- > > Key: ZOOKEEPER-2684 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2684 > Project: ZooKeeper > Issue Type: Bug > Components: server > Affects Versions: 3.6.0 > Environment: with pretty heavy load on a real cluster > Reporter: Ryan Zhang > Assignee: Ryan Zhang > Priority: Blocker > Attachments: ZOOKEEPER-2684.patch > > > We deployed our build with ZOOKEEPER-2024 and it quickly started to crash= with the following error > atla-buh-05-sr1.prod.twttr.net: 2017-01-18 22:24:42,305 - ERROR [CommitPr= ocessor:2] -org.apache.zookeeper.server.quorum.CommitProcessor.run(CommitPr= ocessor.java:268) =E2=80=93 Got cxid 0x119fa expected 0x11fc5 for client se= ssion id 1009079ba470055 > atla-buh-05-sr1.prod.twttr.net: 2017-01-18 22:32:04,746 - ERROR [CommitPr= ocessor:2] -org.apache.zookeeper.server.quorum.CommitProcessor.run(CommitPr= ocessor.java:268) =E2=80=93 Got cxid 0x698 expected 0x928 for client sessio= n id 4002eeb3fd0009d > atla-buh-05-sr1.prod.twttr.net: 2017-01-18 22:34:46,648 - ERROR [CommitPr= ocessor:2] -org.apache.zookeeper.server.quorum.CommitProcessor.run(CommitPr= ocessor.java:268) =E2=80=93 Got cxid 0x8904 expected 0x8f34 for client sess= ion id 51b8905c90251 > atla-buh-05-sr1.prod.twttr.net: 2017-01-18 22:43:46,834 - ERROR [CommitPr= ocessor:2] -org.apache.zookeeper.server.quorum.CommitProcessor.run(CommitPr= ocessor.java:268) =E2=80=93 Got cxid 0x3a8d expected 0x3ebc for client sess= ion id 2051af11af900cc > clearly something is not right in the new commit processor per session qu= eue implementation. -- This message was sent by Atlassian JIRA (v6.4.14#64029)