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 B37E96EC40; Sat, 3 Jul 2021 00:36:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B37E96EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1625261782; bh=seSIU8Obu8sCSJtQH/LZFsPyW0p0mJ1o7mHkKg7gm8w=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=d7iEBUwRdfcgulq6gorF0Jrddgb1Jo4gTHSFhUjpfAMW7O/UfUBf4AyfJz60YAB4M fmrfS+oUOFqVI9oNaTE3bwdnjMtNgcFd2kfDcA4O5DwB9l2qWiyQugiivO95eea/ih Ft5rnjRTNTZdPbAj1xs8MThI76sZGKX6gRW0wMKA= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 96A026EC40 for ; Sat, 3 Jul 2021 00:36:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 96A026EC40 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lzQpd-00052u-Sl; Sat, 03 Jul 2021 00:36:18 +0300 To: Oleg Babin , tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org References: <1b0facbff8f285ec54c03a3ec68fca777f4828a3.1625177222.git.v.shpilevoy@tarantool.org> <2dc3ff07-5f6e-294f-670a-5dcc5948c839@tarantool.org> Message-ID: <6073e325-a77b-c5c1-8950-950f41c36ac3@tarantool.org> Date: Fri, 2 Jul 2021 23:36:16 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <2dc3ff07-5f6e-294f-670a-5dcc5948c839@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD954DFF1DC42D673FB517E8D1A7E34673E94B235AA752823A6182A05F538085040B9614CBD1014DB965543B89BA52DC7863BD093B0A0E6D2EC6F94E292E00D1531 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7484B509D84968742EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B23888C9749F3CAC8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D80A0686FE1BBAC2D1E8C95E0EBB40B6C2117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCE2CCD8F0CAA010FB389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC85DBE5CE84B47B0E4117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063757B1FBEA53BC6EDBEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C9783159B2D2D64495C82F57D12FD7D753A721 X-C1DE0DAB: 0D63561A33F958A58C1682EFC05D07E6193032E58A05A03B3EC98B5AFD49DBCBD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75342909995EBBA6E4410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3451BBE684D17D722182C2CE735859CB0A12745CAA2FC655D20EAACB90AF803BC6B482DE625B6487281D7E09C32AA3244C466C3FC184A49DD73B1639A3271CDBB1250262A5EE9971B0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj/yEXjM+E11D/2O61IfjS/w== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822D393EC0835DDD57293E0F48D4672D2363841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH vshard 6/6] router: update master using a hint from storage 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the review! >> diff --git a/vshard/error.lua b/vshard/error.lua >> index e2d1a31..fa7bdaa 100644 >> --- a/vshard/error.lua >> +++ b/vshard/error.lua >> @@ -20,7 +20,7 @@ local error_message_template = { >>       [2] = { >>           name = 'NON_MASTER', >>           msg = 'Replica %s is not a master for replicaset %s anymore', >> -        args = {'replica_uuid', 'replicaset_uuid'} >> +        args = {'replica_uuid', 'replicaset_uuid', 'master_uuid'} > Error format string still contains only 2 arguments. Is it ok? Yes. All the 'args' are remembered as the error object attributes. I can use it to attach information which I don't want to add to the message or simply can't. Here I can't, because master_uuid might be nil. If it would be in the format, it would be displayed as 'nil' sometimes, which would be confusing. >> diff --git a/vshard/replicaset.lua b/vshard/replicaset.lua >> index 7747258..660c786 100644 >> --- a/vshard/replicaset.lua >> +++ b/vshard/replicaset.lua >> @@ -570,6 +570,70 @@ local function rebind_replicasets(replicasets, old_replicasets) >>       end >>   end >>   +-- >> +-- Let the replicaset know @a old_master_uuid is not a master anymore, should >> +-- use @a candidate_uuid instead. >> +-- Returns whether the request, which brought this information, can be retried. >> +-- >> +local function replicaset_update_master(replicaset, old_master_uuid, >> +                                        candidate_uuid) >> +    local is_auto = replicaset.is_auto_master >> +    local replicaset_uuid = replicaset.uuid >> +    if old_master_uuid == candidate_uuid then >> +        -- It should not happen ever, but be ready to everything. >> +        log.warn('Replica %s in replicaset %s reports self as both master '.. >> +                 'and not master', master_uuid, replicaset_uuid) >> +        return is_auto >> +    end >> +    local master = replicaset.master >> +    if not master then >> +        if not is_auto or not candidate_uuid then >> +            return is_auto >> +        end >> +        local candidate = replicaset.replicas[candidate_uuid] > > AFAIU it means that candidate_uuid doesn't belong to replicaset. > > Why is it true? It can happen if router config is different from the storage's due to any reason. If the master is not in router's config, it won't be able to find it by UUID.