Fix
This commit is contained in:
parent
1643a8e2c0
commit
755f358dfa
|
@ -162,6 +162,7 @@ proc raftNodeReplicateSmCommand*[SmCommandType, SmStateType](node: RaftNode[SmCo
|
|||
withRLock(node.raftStateMutex):
|
||||
var
|
||||
logEntry: RaftLogEntry[SmCommandType](term: node.currentTerm, data: cmd, entryType: etData)
|
||||
|
||||
raftNodeLogAppend(node, logEntry)
|
||||
|
||||
for peer in node.peers:
|
||||
|
|
|
@ -32,7 +32,7 @@ proc raftNodeApplyLogEntry*[SmCommandType, SmStateType](node: RaftNode[SmCommand
|
|||
|
||||
if entryIndex > node.lastApplied:
|
||||
debug "Applying log entry: ", node_id=node.id, entryIndex=entryIndex, entry=repr(logEntry)
|
||||
raftNodeSmApply(node.stateMachine, raftNodeLogEntryGet(node, entryIndex))
|
||||
raftNodeSmApply(node.stateMachine, raftNodeLogEntryGet(node, entryIndex).data.get)
|
||||
node.lastApplied = entryIndex
|
||||
|
||||
else:
|
||||
|
|
|
@ -144,6 +144,8 @@ proc raftNodeScheduleHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCom
|
|||
|
||||
proc raftNodeSendHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) {.async.} =
|
||||
debug "Raft Node sending Heart-Beat to peers", node_id=node.id
|
||||
|
||||
withRLock(node.raftStateMutex):
|
||||
for raftPeer in node.peers:
|
||||
let msgHrtBt = RaftMessage[SmCommandType, SmStateType](
|
||||
op: rmoAppendLogEntry, senderId: node.id, receiverId: raftPeer.id,
|
||||
|
@ -151,6 +153,7 @@ proc raftNodeSendHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommand
|
|||
prevLogIndex: raftNodeLogIndexGet(node) - 1, prevLogTerm: if raftNodeLogIndexGet(node) > 0: raftNodeLogEntryGet(node, raftNodeLogIndexGet(node) - 1).term else: 0
|
||||
)
|
||||
discard node.msgSendCallback(msgHrtBt)
|
||||
|
||||
raftNodeScheduleHeartBeat(node)
|
||||
|
||||
proc raftNodeScheduleElectionTimeout*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
||||
|
|
Loading…
Reference in New Issue