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 51EA76EC5F; Tue, 20 Apr 2021 23:29:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 51EA76EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618950592; bh=jiCrdcXNbEfjqCgYdF2IrRHzLR4KYgNWeTTLsmNtqZk=; 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=jL2poCC0MKHlMkcxFaBsfz7PH6PFgu7r+v9rlOVZgq/EftRwFCBV9PAPq9Z9FjdzW 4a7I8BPqoWoMrvemcMJHhCuBvcDaYYOORNxHddEw6WWX6SuL97kVU+IlWUkxRHfwB2 XFIcIc1AqVhHoLu8KP2nq0xy4r7k5hLiIgV571fI= Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (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 055E96EC5F for ; Tue, 20 Apr 2021 23:29:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 055E96EC5F Received: by smtp34.i.mail.ru with esmtpa (envelope-from ) id 1lYx0J-0001HI-89; Tue, 20 Apr 2021 23:29:51 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <60125d86-5142-c616-bbed-d479f7454219@tarantool.org> Date: Tue, 20 Apr 2021 23:29:50 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 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-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E74806859AC5FE18436AE548FEBC73F726D7B182A05F5380850407029B88FF44717CF7FDE7132733B23C91B7490C589524C5BC5DCC1A740364E04 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78AC0750F3304E924EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A9E1EE47BE02EAD28638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2D3F6DF486F69948F92F8E3CFFA9B139EE5D25F19253116ADD2E47CDBA5A96583C09775C1D3CA48CFE97D2AE7161E217F117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE79AE9BAF3542BD4619FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89FB26E97DCB74E625257739F23D657EF2BB5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C9783119894B2FFD0DC362BE75460A6CDB2857 X-C1DE0DAB: 0D63561A33F958A5B607028B5100C1B6BEE1025BBEE1A764448AAA790CCB3B8BD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34505665BFD4C70705C718E906649ED40B485BEA4E54983A5361E59A3275C0026A38AA3FCA8E27B1B41D7E09C32AA3244CB43AF77FBAFD1701FE1581D5592080BC5595C85A795C7BAEFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojlPRl29Bx4WG1204uGV8z4w== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A4464A8C97A934CEA2656FA6605F4CAD8585011D432433036630424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 07/12] raft: filter rows based on known peer 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" 16.04.2021 19:25, Serge Petrenko пишет: > Start writing the actual leader term together with the PROMOTE request > and process terms in PROMOTE requests on receiver side. > > Make applier only apply synchronous transactions from the instance which > has the greatest term as received in PROMOTE requests. > > Closes #5445 > A couple of fixes on top: Only apply  PROMOTE when it's for a greater term than already received. If promote tries to confirm entries for instance id other than limbo->owner_id rollback everything that's unconfirmed. ========================================= diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 14e87cd3d..5f72c891f 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -643,14 +643,21 @@ complete:  }  void -txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req) +txn_limbo_process(struct txn_limbo *limbo, struct synchro_request *req)  {         uint64_t term = req->term;         uint32_t origin = req->origin_id;         if (txn_limbo_replica_term(limbo, origin) < term) {                 vclock_follow(&limbo->promote_term_map, origin, term); -               if (term > limbo->promote_greatest_term) +               if (term > limbo->promote_greatest_term) {                         limbo->promote_greatest_term = term; +               } else if (req->type == IPROTO_PROMOTE) { +                       /* +                        * PROMOTE for an old term should be ignored. +                        * For CONFIRM and ROLLBACK term is unused. +                        */ +                       return; +               }         }         if (req->replica_id == REPLICA_ID_NIL) {                 /* @@ -665,7 +672,15 @@ txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req)                  * data from an old leader, who has just started and written                  * confirm right on synchronous transaction recovery.                  */ -               return; +               if (req->type != IPROTO_PROMOTE) { +                       return; +               } else { +                       /* +                        * A PROMOTE request for a foreign master - roll back +                        * everyting in limbo. +                        */ +                       req->lsn = 0; +               }         }         switch (req->type) {         case IPROTO_CONFIRM: diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index e409ac657..a06fabccc 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -302,7 +302,7 @@ txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry);  /** Execute a synchronous replication request. */  void -txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req); +txn_limbo_process(struct txn_limbo *limbo, struct synchro_request *req);  /**   * Waiting for confirmation of all "sync" transactions =========================================== -- Serge Petrenko