From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 8AEE96F87A; Fri, 16 Apr 2021 19:28:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8AEE96F87A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618590529; bh=6dtw8cn3q/6yAP4StXhBZdU0pXBeccRLagSEQSRnUP8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UXybBhcflL5jKLAYJfK9dkX3ifZmAX8fgWHFwS0pT2a9ciKywr5vhPtDjNpL9plWE 5791tIreHkcxKT1Ryr404khnZ1e4hSqZQRPY7fi0+lCpLFJA295D8xiX52a3fwrHxV DO9oB+S+wMfzD4tLpx75ZFvdJlWNPd6hJuj5Oh6o= Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F31446FF9F for ; Fri, 16 Apr 2021 19:25:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F31446FF9F Received: by smtp17.mail.ru with esmtpa (envelope-from ) id 1lXRI2-00008e-A0; Fri, 16 Apr 2021 19:25:54 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Fri, 16 Apr 2021 19:25:37 +0300 Message-Id: <0ab8807e9374184df758b7d8ab99805317a1a871.1618590211.git.sergepetrenko@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E74806859AC5FE18436AEED970E897805ADA4182A05F5380850400A17BE2332CA35ACE90BB11A8DBBF8404890A8901397C896295F984A9108EB50 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE720512D700D036E85EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B8A896DD3ADA3FA48638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2C21D9AACA057D979A62CEE327EB6EA25AA867293B0326636D2E47CDBA5A96583C09775C1D3CA48CFE3800B164E348C91117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7678748765F3C1EF79FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE70D68ACA4652F57B3D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED62991661749BA6B97735B869F6C56E712840CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3CE9959E2676FD87735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADBD35190C2CBFC13E9908DE8AC318C1F8 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7AB710B7F030ED88FCB8E5CFDA2BA57D29EA33BA1510BC3C23B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EE6683D9E546CC620ED6AA894A9B70808FD52C7943FC2D7DADAA5658F38400180ECE54C1A0DB2FFE1D7E09C32AA3244C607B973F3F9112CDC8C0BC8C5578463EB038C9161EF167A1927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj3S6P1v0GIqRRVvApeyaeUw== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F8DF49C5E8585DB537A3180237FB1F597740E9F21FEC7FCA0C424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 06/12] box: write PROMOTE even for empty limbo X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" PROMOTE entry will be used to mark limbo ownership transition besides emptying the limbo. So it has to be written every time `box.ctl.clear_synchro_queue()` succeeds. Even when the limbo was already empty. Part of #5445 --- src/box/box.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index e0bed74f1..9d45e211e 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1502,19 +1502,18 @@ box_clear_synchro_queue(bool try_wait) "simultaneous invocations"); return -1; } - /* - * XXX: we may want to write confirm + rollback even when the limbo is - * empty for the sake of limbo ownership transition. - */ - if (!is_box_configured || txn_limbo_is_empty(&txn_limbo)) + + if (!is_box_configured) return 0; uint32_t former_leader_id = txn_limbo.owner_id; - assert(former_leader_id != REPLICA_ID_NIL); - if (former_leader_id == instance_id) - return 0; - + int64_t wait_lsn = txn_limbo.confirmed_lsn; + int rc = 0; + int quorum = replication_synchro_quorum; in_clear_synchro_queue = true; + if (txn_limbo_is_empty(&txn_limbo)) + goto promote; + if (try_wait) { /* Wait until pending confirmations/rollbacks reach us. */ double timeout = 2 * replication_synchro_timeout; @@ -1528,8 +1527,11 @@ box_clear_synchro_queue(bool try_wait) * Our mission was to clear the limbo from former leader's * transactions. Exit in case someone did that for us. */ - if (txn_limbo_is_empty(&txn_limbo) || - former_leader_id != txn_limbo.owner_id) { + if (former_leader_id != txn_limbo.owner_id) { + /* + * TODO: error once we see someone else has become the + * leader already. + */ in_clear_synchro_queue = false; return 0; } @@ -1540,12 +1542,11 @@ box_clear_synchro_queue(bool try_wait) * in the limbo must've come through the applier meaning they already * have an lsn assigned, even if their WAL write hasn't finished yet. */ - int64_t wait_lsn = txn_limbo_last_synchro_entry(&txn_limbo)->lsn; + wait_lsn = txn_limbo_last_synchro_entry(&txn_limbo)->lsn; assert(wait_lsn > 0); - int quorum = replication_synchro_quorum; - int rc = box_wait_quorum(former_leader_id, wait_lsn, quorum, - replication_synchro_timeout); + rc = box_wait_quorum(former_leader_id, wait_lsn, quorum, + replication_synchro_timeout); if (rc == 0) { if (quorum < replication_synchro_quorum) { diag_set(ClientError, ER_QUORUM_WAIT, quorum, @@ -1556,6 +1557,7 @@ box_clear_synchro_queue(bool try_wait) "new synchronous transactions appeared"); rc = -1; } else { +promote: /* * Term parameter is unused now, We'll pass * box_raft()->term there later. -- 2.24.3 (Apple Git-128)