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 B7F036EC5F; Mon, 12 Apr 2021 22:42:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B7F036EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618256577; 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=G4OW1DC+QeNgEWf1HrK9EQ+ns2MLqI/rS13GkkgQKzaWVcPP7EHuF6nq2hrHA54Wn muJMIwroWrpr/vlAWo89J9PtQauI3asRhU8LBJI7ROgbSIGKRaCn1Rytr3XOHx3G1c iCHpZKzGXvvNKEpxZcywkStdGUHIWF6KTrz0aSM0= Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [94.100.177.113]) (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 C99286BD18 for ; Mon, 12 Apr 2021 22:40:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C99286BD18 Received: by smtp53.i.mail.ru with esmtpa (envelope-from ) id 1lW2Q8-0008Az-4c; Mon, 12 Apr 2021 22:40:28 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Mon, 12 Apr 2021 22:40:18 +0300 Message-Id: <8d03ea66f571407efcd76a2e50b81420bd716eeb.1618256019.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480BE79914FF86F9151AC38CC435EA4A654182A05F538085040060AF008338C3453C3E4805B21E70CFA40B4240EDCB5B2BDD84E026CE6C3A6D3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E28898EEFCE30F12EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E0B09B181166DBFC8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2E42AA69111F9A23F027AA4BAEA5AF3000E47C10036089472D2E47CDBA5A96583C09775C1D3CA48CFE3800B164E348C91117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE75C266B62551496319FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7CB4EC43BE25707E8D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED62991661749BA6B97735448CF9D3A7B2C848CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C382C525EC1B8D9DED35872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADF048BB164F7B76AFB9D5EA8F28179639 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7AE4F16467A2949FE9C8BE8753C343DD6FA7F9F4F10E002726B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344888A9AABCDD3225BE96A528EF49DDAC4270A661E510FF9BBBBE89A8ACC5FE2E3FC20C86BB1D3EFB1D7E09C32AA3244CCC8ACA29DBA7E606F34B60B41B7F2A5DA8CE788DE6831205927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojq8JA+pXcDun2VjFwY1dZgw== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F8AFCB052CDF231E7B72BACEAC82788E4AA419A7BE50F8661C424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 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)