You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Lokesh Jain (JIRA)" <ji...@apache.org> on 2019/04/23 12:50:00 UTC

[jira] [Comment Edited] (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:comment-tabpanel&focusedCommentId=16824091#comment-16824091 ] 

Lokesh Jain edited comment on RATIS-495 at 4/23/19 12:49 PM:
-------------------------------------------------------------

[~andywu] Thanks for reporting the issue!

[~szetszwo] Thanks for working on this! The patch looks good to me. +1. I have committed this to master branch.


was (Author: ljain):
[~szetszwo] Thanks for working on this! The patch looks good to me. +1. I have committed this to master branch.

> 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, r495_20190314.patch, r495_20190401.patch, r495_20190423.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)