Andy Wu created RATIS-495:
-----------------------------

             Summary: Leader Election thread might crash without coming back
                 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


In some scenario, 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}
 

Fix: Change ExecutionException into Exception. Also I need to figure out what 
is causing this RunTimeException. 



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

Reply via email to