[
https://issues.apache.org/jira/browse/RATIS-495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tsz Wo Nicholas Sze updated RATIS-495:
--------------------------------------
Description:
When two servers is (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}
was:
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.
Summary: Leader Election thread might crash if two servers having the
same id (was: Leader Election thread might crash without coming back)
[~andywu], these are good suggestions. Thanks.
Updated summary and description.
> 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
> Priority: Major
>
> When two servers is (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)