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 40C626901E; Wed, 14 Apr 2021 17:19:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 40C626901E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618409993; bh=dT++FWYdvjy2IdIbWeGeDlQX9rYOnv2OYO+GCuO/xvA=; 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=aqUnK5cIWX2y5IOTrB6XEaKJhV/nhmsLpuL0QfQfr8CQltN8BGEwONb5hDnOH16Tr SixNN3TxUvmcZOF+HJxCoLDarRfK3tVzkGiLLZoyFsIl3l1+ULc+PoEp4mqWb7GTyZ tUt2CZSN2uPl3NWPf6o18HLLnacU75RKaIbEDcnw= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [94.100.177.101]) (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 36E846901E for ; Wed, 14 Apr 2021 17:17:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 36E846901E Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1lWgKc-000456-Cx; Wed, 14 Apr 2021 17:17:26 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Wed, 14 Apr 2021 17:17:15 +0300 Message-Id: <486f83c475f51cd3e05edabfb56c567cd85a50ad.1618409665.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: 4F1203BC0FB41BD92FFCB8E6708E74807BAE725B9AE625DE765B0E193B5B7687182A05F5380850407A4631DDD592A78DFF0353DF89EBCD3052410A0E77693A1B1FB42E96EA4D7B70 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE769420192704DB0E7EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377A2EA98384B91C6C8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2C1C661019676F9E73D2959DE8E9AA6EA9414A38D98B987DBD2E47CDBA5A96583C09775C1D3CA48CF776A0366D588B3C3117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE722C7672CDBCC22789FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7A94733CAF7D346477B076A6E789B0E97A8DF7F3B2552694A1E7802607F20496D49FD398EE364050F4B6963042765DA4B148812EF9080FC94B3661434B16C20AC78D18283394535A9E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6D0C9BB9AE6BD5D69089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7AB91D1FC05742914464B35F056FC404B987420961F6206DCDB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A541DB4061E938329CC994237737EDD2B6F642DB1CD441709247AE5B75745B09D5E4F2CD208FBFA51D7E09C32AA3244C44A5009C999C50BF3B7C3A0A173E0153F26BFA4C8A6946B8927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojrcJA+pXcDuko9SdmBsAX3Q== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F832D6326595065D5CA5E8F417A2FF7091BF2DA60DD686805E424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v3 05/10] 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 | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 9adb6ba46..722fc23b7 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,11 +1542,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 +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)