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 E28FD6BD15; Sun, 11 Apr 2021 20:58:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E28FD6BD15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618163920; bh=sjt5wZCnhCKkSQiZFtmRalxxiPB9kj5KWgePnw2kszk=; 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=YObp1Hwhx2+FcHzMyOgoH6dWCcU0GPYmt6yr8vtTnkdzBLfM2N4XY35uWjW8411D3 fKo3tENAmh5qv05nYN3EWGoj0Y7woGt+71HnYwLFQHyVHqy54wsIMqF/4mktawXWlm bEwNJe1ikHoYK+hrVzgyszGsUyWx5goItman0jIo= Received: from smtp42.i.mail.ru (smtp42.i.mail.ru [94.100.177.102]) (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 06A756BD16 for ; Sun, 11 Apr 2021 20:56:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 06A756BD16 Received: by smtp42.i.mail.ru with esmtpa (envelope-from ) id 1lVeJh-0001Ua-9L; Sun, 11 Apr 2021 20:56:13 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Sun, 11 Apr 2021 20:56:00 +0300 Message-Id: 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: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480EBD5CA77A668ECB87DA2124B0A8E6609182A05F53808504061B21DAA13B08EA5934AE01D3076C535ECBCF1ACB68BB3DDD5343F038B6581E2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE777D9B7C31E2C1495EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D7C7E03580C3DB018638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B284E8C2378C025C338A22B13F5E8E6C8B3EADAC849D614696D2E47CDBA5A96583C09775C1D3CA48CFE3800B164E348C91117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7302A6E9DBA3751109FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE75F402D8BE110B5E6D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C0D94E105876FE7799B3661434B16C20AC78D18283394535A9E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B67BEEC15D15C45022089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24209795067102C07E8F7B195E1C9783191471F51605917AD1D9CBE3238DE1566 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7AFD80A448CD634CA558BDE406262AF96204F16FBB2482866CB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348F9E8EBB462314872F6AE4A01085C9CD1054E3A0C8523BB9D58B0BA1B0142D0B69DC8099018665C51D7E09C32AA3244C5B165DA0351C738736DBF268B9C31D5B24AF4FAF06DA24FD927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXjz3uqod8pbhSUIX8zv2962 X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F8A3D5B6EFD69438694E8B1B2D1A7F40DB8AA5F74632988EB1424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 5/9] 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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 8aba051a2..b093341d3 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,9 @@ 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 became the leader + // already. in_clear_synchro_queue = false; return 0; } @@ -1540,11 +1540,10 @@ 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, + rc = box_wait_quorum(former_leader_id, wait_lsn, quorum, replication_synchro_timeout); if (rc == 0) { if (quorum < replication_synchro_quorum) { @@ -1556,6 +1555,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)