sofastack / sofa-jraft

A production-grade java implementation of RAFT consensus algorithm.
https://www.sofastack.tech/projects/sofa-jraft/
Apache License 2.0
3.59k stars 1.15k forks source link

TestLeaderStopAndReElectWithPriority unittest run failure #411

Closed killme2008 closed 4 years ago

killme2008 commented 4 years ago

It happens frequently, maybe we have to investigate it.

testLeaderStopAndReElectWithPriority(com.alipay.sofa.jraft.core.NodeTest)  Time elapsed: 7.238 sec  <<< FAILURE!
java.lang.AssertionError: expected:<60> but was:<10>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at com.alipay.sofa.jraft.core.NodeTest.testLeaderStopAndReElectWithPriority(NodeTest.java:1051)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
zongtanghu commented 4 years ago

This issue can be assigned to me!I will investigate the reason and fix it! @killme2008 @fengjiachun

fengjiachun commented 4 years ago

@zongtanghu It's yours

fengjiachun commented 4 years ago

any progress? @zongtanghu

zongtanghu commented 4 years ago

I look into the findTheNextCandidate method which is in the ReplicatorGroupImpl class.In this method, it will choose the node which logindex is much more enough become leader rather than the node which priority value is larger.

image

zongtanghu commented 4 years ago

So, in this testLeaderStopAndReElectWithPriority method, if the node with priority 10 has more enough logindex file than node with priority 60, the node with priority 10 will be the leader. @killme2008 @fengjiachun