You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Tsz Wo Nicholas Sze (JIRA)" <ji...@apache.org> on 2019/03/13 00:32:00 UTC

[jira] [Assigned] (RATIS-495) Leader Election thread might crash if two servers having the same id

     [ https://issues.apache.org/jira/browse/RATIS-495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tsz Wo Nicholas Sze reassigned RATIS-495:
-----------------------------------------

    Assignee: Tsz Wo Nicholas Sze

r495_20190312.patch: adds some checks.

> Leader Election thread might crash if two servers having the same id
> --------------------------------------------------------------------
>
>                 Key: RATIS-495
>                 URL: https://issues.apache.org/jira/browse/RATIS-495
>             Project: Ratis
>          Issue Type: Bug
>    Affects Versions: 0.2.0
>            Reporter: Andy Wu
>            Assignee: Tsz Wo Nicholas Sze
>            Priority: Major
>         Attachments: r495_20190312.patch
>
>
> When two servers are (mis)configured with the same id, thread running LeaderElection#waitForResults might crash. 
> {code:java}
> try {
> if (conf.hasMajority(votedPeers, server.getId())) {
> }
> } catch(ExecutionException e) {}
>  
> boolean hasMajority(Collection<RaftPeerId> others, RaftPeerId selfId) { 
> Preconditions.assertTrue(!others.contains(selfId)); 
> return conf.hasMajority(others, selfId) && (oldConf == null || oldConf.hasMajority(others, selfId));
> }
> {code}
> Preconditions.assertTrue(!others.contains(selfId)); statement inside RaftConfiguration#hasMajority() might throw IllegalStateException. This RunTimeException will kill thread running LeaderElection#waitForResults code.
> stacktrace:
> {code:java}
> Exception in thread "Thread-13" java.lang.IllegalStateException
>  at org.apache.ratis.util.Preconditions.assertTrue(Preconditions.java:33)
>  at org.apache.ratis.server.impl.RaftConfiguration.hasMajority(RaftConfiguration.java:211)
>  at org.apache.ratis.server.impl.LeaderElection.waitForResults(LeaderElection.java:225)
>  at org.apache.ratis.server.impl.LeaderElection.askForVotes(LeaderElection.java:146)
>  at org.apache.ratis.server.impl.LeaderElection.run(LeaderElection.java:102){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)