[
https://issues.apache.org/jira/browse/RATIS-495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16788373#comment-16788373
]
Andy Wu commented on RATIS-495:
-------------------------------
Yes [~szetszwo] , I misconfigured the server id for one server. I was wondering:
# If it makes sense to make the error message more informative, so it will be
easier to debug.
# Also, it might be nice to add a check here to make sure all servers are
configured correctly. Because if three servers are marked as s0, s0, and s2. If
s2 asks for the votes, it might pass the leader election, and the system will
move forward. Have a sanity check here might be helpful. Or is there any way to
perform an earlier check?
> 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
> Priority: Major
>
> 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)