You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes NPE happens in NodeImpl#handleRequestVoteRequest on the line
final boolean logIsOk = new LogId(request.getLastLogIndex(), request.getLastLogTerm())
.compareTo(lastLogId) >= 0;
It happens when we call o.getTerm() in
final int c = Long.compare(getTerm(), o.getTerm());
in com.alipay.sofa.jraft.entity.LogId#compareTo, because o is null. It happens because
final LogId lastLogId = this.logManager.getLastLogId(true);
return null.
The reason of that is because when we
offerEvent(c, EventType.LAST_LOG_ID);
in com.alipay.sofa.jraft.storage.impl.LogManagerImpl#getLastLogId, we are in the situation when node is stopping, so this code is called
if (this.stopped) {
ThreadPoolsFactory.runClosureInThread(this.groupId, done, new Status(RaftError.ESTOP, "Log manager is stopped."));
return;
}
in com.alipay.sofa.jraft.storage.impl.LogManagerImpl#offerEvent. That leads to the situation that we count down latch in com.alipay.sofa.jraft.storage.impl.LogManagerImpl.LastLogIdClosure#latch, but do not set com.alipay.sofa.jraft.storage.impl.LogManagerImpl.LastLogIdClosure#lastLogId
Let's discuss a way how to fix it properly. The problem could happen everywhere when we call com.alipay.sofa.jraft.storage.impl.LogManagerImpl#getLastLogId or com.alipay.sofa.jraft.storage.impl.LogManagerImpl#getLastLogIndex(boolean)
The text was updated successfully, but these errors were encountered:
Describe the bug
Sometimes NPE happens in
NodeImpl#handleRequestVoteRequest
on the lineIt happens when we call
o.getTerm()
inin
com.alipay.sofa.jraft.entity.LogId#compareTo
, becauseo
is null. It happens becausereturn null.
The reason of that is because when we
in
com.alipay.sofa.jraft.storage.impl.LogManagerImpl#getLastLogId
, we are in the situation when node is stopping, so this code is calledin
com.alipay.sofa.jraft.storage.impl.LogManagerImpl#offerEvent
. That leads to the situation that we count down latch incom.alipay.sofa.jraft.storage.impl.LogManagerImpl.LastLogIdClosure#latch
, but do not setcom.alipay.sofa.jraft.storage.impl.LogManagerImpl.LastLogIdClosure#lastLogId
Let's discuss a way how to fix it properly. The problem could happen everywhere when we call
com.alipay.sofa.jraft.storage.impl.LogManagerImpl#getLastLogId
orcom.alipay.sofa.jraft.storage.impl.LogManagerImpl#getLastLogIndex(boolean)
The text was updated successfully, but these errors were encountered: