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 1AE436EC40; Fri, 2 Jul 2021 14:49:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1AE436EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1625226549; bh=f6R9m/iQ2gNveggQWJ0V5/Buk4VbOZRirtSpQOoVDww=; 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=aSZhBel3pR0k6mOwNMCOgOGEgl1XOJJF95vmGD0dz/wQxCSvKu78MW0VS6BcD39nT wseCUrRZyH33PMu3Y+5kanj4z6JiMfgGMVnUVUibBIJXZ+i1ZJmSTBuf3RMwQz2Rtl /VNT4Nd0Z9MRFUKWT3BRuYc0rKzuDYbOj4gN3F+I= Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (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 D36D86EC40 for ; Fri, 2 Jul 2021 14:49:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D36D86EC40 Received: by smtp38.i.mail.ru with esmtpa (envelope-from ) id 1lzHfO-0005DT-VL; Fri, 02 Jul 2021 14:49:07 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org References: <1b0facbff8f285ec54c03a3ec68fca777f4828a3.1625177222.git.v.shpilevoy@tarantool.org> Message-ID: <2dc3ff07-5f6e-294f-670a-5dcc5948c839@tarantool.org> Date: Fri, 2 Jul 2021 14:49:06 +0300 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: <1b0facbff8f285ec54c03a3ec68fca777f4828a3.1625177222.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD954DFF1DC42D673FB8EEAA58EF109ED2DCA3B880632F394B8182A05F538085040F0B1ED007CABCC73D1AC2850F394536EB389E4DB5890312F1535E07DD918192A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CE4525FFB91B9BBCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063781E06E36B00F36668638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89FBE780B32470EED52E171735CEB9860117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC60CDF180582EB8FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FE5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DE4DB3626BA78294CCD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE389DDFE3E282F3DD16136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BBEA499411984DA1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24209795067102C07E8F7B195E1C97831F92DC2230794572D0C4CD27AEC68174C X-C1DE0DAB: 0D63561A33F958A5CE2FF91721474519C5E5E02A0B3AA1D473DC5583DD47C369D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753753CEE10E4ED4A7410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340CB2836B82369449E8F83D0780E8D6B156CBD1AE9E83DFA38375C534F7D0F49A492F4A9EE313114B1D7E09C32AA3244CD68E3C8AA44FD77AA58E2CCA6DB8024224AF4FAF06DA24FDFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj/yEXjM+E11DXysTxFeRnDw== X-Mailru-Sender: 583F1D7ACE8F49BD07526C4546A62CBFA8CE9012133DF49953EF5654B9FA4F76695E860E62102A0A23E75C7104EB1B885DEE61814008E47C7013064206BFB89F93956FB04BA385BE9437F6177E88F7363CDA0F3B3F5B9367 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: Oleg Babin via Tarantool-patches Reply-To: Oleg Babin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for your patch. See 2 comments below. On 02.07.2021 01:09, Vladislav Shpilevoy wrote: > Storage sends NON_MASTER error when an attempt happens to make a > read-write request on it while it is not a master. The error > contains UUID of the instance. > > The patch adds to this error a new field - UUID of the master as > it is seen on this storage. Router now uses that information to > quickly switch its read-write requests to the new master. In fact, > this should happen in almost all cases of master auto-discovery on > the router if it occurs under load. > > Closes #75 > --- > test/router/master_discovery.result | 427 ++++++++++++++++++++++++++ > test/router/master_discovery.test.lua | 191 ++++++++++++ > test/router/router.result | 8 +- > vshard/error.lua | 2 +- > vshard/replicaset.lua | 65 ++++ > vshard/router/init.lua | 17 +- > vshard/storage/init.lua | 6 +- > 7 files changed, 706 insertions(+), 10 deletions(-) > > > ... > @@ -1175,6 +1176,7 @@ error_messages > - Use replicaset:connect_replica(...) instead of replicaset.connect_replica(...) > - Use replicaset:down_replica_priority(...) instead of replicaset.down_replica_priority(...) > - Use replicaset:up_replica_priority(...) instead of replicaset.up_replica_priority(...) > + - Use replicaset:update_master(...) instead of replicaset.update_master(...) > - Use replicaset:wait_connected(...) instead of replicaset.wait_connected(...) > ... > _, replica = next(replicaset.replicas) > 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? > }, > [3] = { > name = 'BUCKET_ALREADY_EXISTS', > 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? > + if not candidate then > + return true > + end > + replicaset.master = candidate > + log.info('Replica %s becomes a master as reported by %s for '.. > + 'replicaset %s', candidate_uuid, old_master_uuid, > + replicaset_uuid) > + return true