Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 5/6] replication: use 'score' to find a join-master
Date: Thu, 10 Jun 2021 22:09:24 +0200
Message-ID: <b5447216-1ac9-1ef1-fd58-01a135b45067@tarantool.org> (raw)
In-Reply-To: <YMIplkkvVQF87yw9@grain>

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.

  reply	other threads:[~2021-06-10 20:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04 23:37 [Tarantool-patches] [PATCH 0/6] Instance join should prefer booted instances Vladislav Shpilevoy via Tarantool-patches
2021-06-04 23:37 ` [Tarantool-patches] [PATCH 1/6] replication: refactor replicaset_leader() Vladislav Shpilevoy via Tarantool-patches
2021-06-10 13:54   ` Serge Petrenko via Tarantool-patches
2021-06-04 23:37 ` [Tarantool-patches] [PATCH 2/6] replication: ballot.is_ro -> is_ro_cfg Vladislav Shpilevoy via Tarantool-patches
2021-06-10 13:56   ` Serge Petrenko via Tarantool-patches
2021-06-04 23:37 ` [Tarantool-patches] [PATCH 3/6] replication: ballot.is_loading -> is_ro Vladislav Shpilevoy via Tarantool-patches
2021-06-10 13:58   ` Serge Petrenko via Tarantool-patches
2021-06-04 23:37 ` [Tarantool-patches] [PATCH 4/6] replication: introduce ballot.is_booted Vladislav Shpilevoy via Tarantool-patches
2021-06-10 14:02   ` Serge Petrenko via Tarantool-patches
2021-06-04 23:37 ` [Tarantool-patches] [PATCH 5/6] replication: use 'score' to find a join-master Vladislav Shpilevoy via Tarantool-patches
2021-06-10 14:06   ` Serge Petrenko via Tarantool-patches
2021-06-10 15:02   ` Cyrill Gorcunov via Tarantool-patches
2021-06-10 20:09     ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-06-10 21:28       ` Cyrill Gorcunov via Tarantool-patches
2021-06-04 23:38 ` [Tarantool-patches] [PATCH 6/6] replication: prefer to join from booted replicas Vladislav Shpilevoy via Tarantool-patches
2021-06-06 17:06   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-10 14:14   ` Serge Petrenko via Tarantool-patches
2021-06-06 17:03 ` [Tarantool-patches] [PATCH 7/6] raft: test join to a raft cluster Vladislav Shpilevoy via Tarantool-patches
2021-06-06 23:01   ` Vladislav Shpilevoy via Tarantool-patches
2021-06-10 14:17   ` Serge Petrenko via Tarantool-patches
2021-06-10 15:03 ` [Tarantool-patches] [PATCH 0/6] Instance join should prefer booted instances Cyrill Gorcunov via Tarantool-patches
2021-06-11 20:56 ` Vladislav Shpilevoy via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5447216-1ac9-1ef1-fd58-01a135b45067@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.shpilevoy@tarantool.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git