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 8C8706EC55; Thu, 10 Jun 2021 23:09:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8C8706EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623355767; bh=fuLYVtGk+yNzeMSpRWO3vXmjTxtR87sln+J4jjn7eEI=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=rKNVaVOOnraFOSfpakXFugXqgNpPVOcQU2RBpKMad08dsccH2mwfj5xGcIzs5A2j6 xu+kITjHbCT3cuVySRu0SLqBmMMzVE4+LjSEMj3/5zicQJxpd2sgeHe3h2RMuBiicq LkvqZMPhpIcdiIznbuYMhimcKKQXFrH6GL+XOB1w= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 B49496EC55 for ; Thu, 10 Jun 2021 23:09:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B49496EC55 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lrQzV-0002Yx-WB; Thu, 10 Jun 2021 23:09:26 +0300 To: Cyrill Gorcunov References: <6675abcfa409f1fd6e05a7e7852b42e1a08d1795.1622849790.git.v.shpilevoy@tarantool.org> Message-ID: Date: Thu, 10 Jun 2021 22:09:24 +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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C54EECC50CDFE52CD8E09EC742E3E75A787182A05F538085040601D3C01892498AFF53C44DA28680964FEB08F5CA386D0B01FB473248E265D90 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE761966F250AC1AE21EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371DF52D98DC3592C48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8D592D8FBAE4938B964E4A7624CD57191117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F2CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831C45DFBE4BFE7EB781F3CAEEA48CA7BF2 X-C1DE0DAB: 0D63561A33F958A5A11573DE6785363AB06F7529DD81D6CA3D0AFB7B5711CE22D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EA882B598A209811F1322188C146DD2FB85B91F187B6C828C3E91CE72A2422154ABEB11F828EE89B1D7E09C32AA3244C770C2E440829604039595BD48CA2B500795D98D676DD64D0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojCpYK6nkTlbEtXLZpsiWKdg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822C551725561005D75749CA18B291E93093841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 5/6] replication: use 'score' to find a join-master 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the review! On 10.06.2021 17:02, Cyrill Gorcunov wrote: > On Sat, Jun 05, 2021 at 01:37:59AM +0200, Vladislav Shpilevoy wrote: >> + int score = 0; >> /* >> - * Try to find a replica which has already left >> - * orphan mode. >> + * Prefer instances not configured as read-only via box.cfg, and >> + * not being in read-only state due to any other reason. The >> + * config is stronger because if it is configured as read-only, >> + * it is in read-only state for sure, until the config is >> + * changed. >> */ >> - if (ballot->is_ro && !leader_ballot->is_ro) >> + if (!ballot->is_ro_cfg) >> + score += 5; >> + if (!ballot->is_ro) >> + score += 1; >> + if (leader_score < score) >> + goto elect; >> + if (score < leader_score) >> continue; > > Vlad, if only I'm not missing something obvious we can do simplier > without branching at all, say > > score = (ballot->is_booted << 3) | > (ballot->is_ro_cfg << 2) | > (ballot->is_ro << 1); > > up to you, just an idea. This would work, technically. But TBH I don't see how it is simpler. >> if (cmp == 0 && tt_uuid_compare(&replica->uuid, >> &leader->uuid) > 0) >> continue; >> + elect: > > seems extra tab here? Yes, fixed on the branch.