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 B7BB3714B5; Tue, 5 Oct 2021 16:25:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B7BB3714B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633440323; bh=kgo8C82FKqRI+Pu9ahHY7yIW21IBQ4FYb5Tep9/q/CY=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=w14q4rqTt1koDwi77sB6M0UFq+MlddvIL6Fddp+AFIZNv1gnitG+ewdV3gxSdwkLv 8sC6AVWLNJBvuyLDJn9P7eq7GpDYPWP2sJ0gf0VJadEWDD7BvOpiyF+i3TCNctdk4z l0jMUZx+jyXONGNuobvtu3S98JQT1VNU4yvla624= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (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 4098A714B3 for ; Tue, 5 Oct 2021 16:25:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4098A714B3 Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1mXkRd-0002kW-L5; Tue, 05 Oct 2021 16:25:21 +0300 To: Cyrill Gorcunov Cc: tml , Vladislav Shpilevoy References: <20210930094445.316694-1-gorcunov@gmail.com> <20210930094445.316694-3-gorcunov@gmail.com> <0c64d172-4fa8-29ec-7845-ff772738c09a@tarantool.org> <590f764f-57f1-eeaf-925c-263c29121fd5@tarantool.org> Message-ID: <19aec308-075f-c9f0-44a7-959c9d4a8193@tarantool.org> Date: Tue, 5 Oct 2021 16:25:21 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9064ADF4728AA0EE956D43A9B567FDD9A8B13701973EA0578182A05F538085040D4727C8EC28B0F7F5E0A2D2FA526C32834B24BF4FB4440423584DCCE5002BAAD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FACE2B07D13A236DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D7F1BE85E7B0CA818638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82F265F42C023AC120614D510D601FBD6117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520140C956E756FBB7AC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6753C3A5E0A5AB5B7089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5D5C02B038D52815A05AA4E77D98FD31C8765AA84EA6F1C69D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75BFC02AB3DF06BA5A410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348B532EA2091F4FF6276E2CDF203D8756D7609B1745C0910BB52936AB8D7EE2A6E8879F475CA752C01D7E09C32AA3244C491FC6807F326A1B7FD389E9AE9E59D305AB220A9D022EBCFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojhAh8SZXECpCxzim9gllpFw== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A44677E2A77131E61104C119E8AC04CB1BFA17C8473AD56A2F06424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v19 2/3] qsync: order access to the limbo terms 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 05.10.2021 00:53, Cyrill Gorcunov пишет: > On Fri, Oct 01, 2021 at 03:37:18PM +0300, Serge Petrenko wrote: >> Shouldn't we guard limbo->owner as well? >> Otherwise you may start writing confirm for an old leader once promote for a >> new one is already in progress. >> >> I don't remember us discussing this before, so, maybe I'm just confused. > Seems I still don't follow. Look, currently limbo::owner_id is assigned > from the one place: > > txn_limbo_process_core > txn_limbo_process_begin(limbo) > txn_limbo_read_demote | txn_limbo_read_promote > ... > limbo->owner_id = replica_id; > > The txn_limbo_process_core is called from console (via box.ctl.promote|demote > commands) or via applier. When it comes from console then we still take the > lock before write into the journal > > static void > box_issue_promote(uint32_t prev_leader_id, int64_t promote_lsn) > { > struct raft *raft = box_raft(); > assert(raft->volatile_term == raft->term); > assert(promote_lsn >= 0); > struct synchro_request req = { > .type = IPROTO_RAFT_PROMOTE, > .replica_id = prev_leader_id, > .origin_id = instance_id, > .lsn = promote_lsn, > .term = raft->term, > }; > --> txn_limbo_process_begin(&txn_limbo); > --> txn_limbo_write_promote(&txn_limbo, req.lsn, req.term); > txn_limbo_process_core(&txn_limbo, &req); > assert(txn_limbo_is_empty(&txn_limbo)); > txn_limbo_process_commit(&txn_limbo); > } > > thus console commands and applier are serialized. Or I miss something > obvious? Here's what can happen. You're the old leader, and you've received a promote from someone else already, it's being written now. Now some replica sends you an ack. You enter txn_limbo_ack (it doesn't check the latch). txn_limbo_ack() may result in writing a CONFIRM. The PROMOTE is already in progress, so you'll end up writing CONFIRM for a wrong leader id (your own) after PROMOTE is written. -- Serge Petrenko