You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ratis.apache.org by Junkai Xue <jx...@apache.org> on 2023/03/01 22:16:35 UTC

Question regarding leader election

Hi Folks,

I am new to Ratis. I have a question about the leader election. I started 3
RaftServer and get RaftClient from the Division. I get the LeaderID as
RaftServer 2 from RaftClient from server 0

But when I stop RaftServer 2:
1. LeaderId from another live RaftServer 0 is still showing RaftServer 2 is
LEADER.
2. When I get peers from Division. RaftServer 2 is still showing as
FOLLOWER as the starting role.

So my question is:
1. Will leader election happen automatically when RaftServer closes?
2. If yes, how can I get the latest Leader info?
3. Let's say RaftServer 2 will not come back. I would like to remove it
from this raft group. How can I do this operation?

BTW, I was using the Server class unde FileStore example and did the
experiment. Maybe I am using it in the wrong way.

Best,

Junkai

Re: Question regarding leader election

Posted by Tsz Wo Sze <sz...@gmail.com>.
Hi Junkai,

> I started 3 RaftServer and get RaftClient from the Division. I get the
LeaderID as RaftServer 2 from RaftClient from server 0

This is not the way to get leader id since the client in that server may
not have updated its leader id.  Instead,
use Division.getInfo().getLeaderId(), which will return the new leader once
the leader has been changed.

1. Yes.
2. See above.
3. Use RaftClient.admin().setConfiguration(..).

Thanks for your questions.
Tsz-Wo


On Wed, Mar 1, 2023 at 2:16 PM Junkai Xue <jx...@apache.org> wrote:

> Hi Folks,
>
> I am new to Ratis. I have a question about the leader election. I started
> 3 RaftServer and get RaftClient from the Division. I get the LeaderID as
> RaftServer 2 from RaftClient from server 0
>
> But when I stop RaftServer 2:
> 1. LeaderId from another live RaftServer 0 is still showing RaftServer 2
> is LEADER.
> 2. When I get peers from Division. RaftServer 2 is still showing as
> FOLLOWER as the starting role.
>
> So my question is:
> 1. Will leader election happen automatically when RaftServer closes?
> 2. If yes, how can I get the latest Leader info?
> 3. Let's say RaftServer 2 will not come back. I would like to remove it
> from this raft group. How can I do this operation?
>
> BTW, I was using the Server class unde FileStore example and did the
> experiment. Maybe I am using it in the wrong way.
>
> Best,
>
> Junkai
>