Fix Cluster Test random hanging issue
This commit is contained in:
parent
d11190bc5d
commit
fba4ac836f
|
@ -118,7 +118,7 @@ template RaftTimerCreate(timerInterval: int, timerCallback: RaftTimerCallback):
|
||||||
|
|
||||||
# Timers scheduling stuff etc.
|
# Timers scheduling stuff etc.
|
||||||
proc RaftNodeScheduleHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
proc RaftNodeScheduleHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
||||||
node.heartBeatTimer = RaftTimerCreate(130, proc() = asyncSpawn RaftNodeSendHeartBeat(node))
|
node.heartBeatTimer = RaftTimerCreate(150, proc() = asyncSpawn RaftNodeSendHeartBeat(node))
|
||||||
|
|
||||||
proc RaftNodeSendHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) {.async.} =
|
proc RaftNodeSendHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) {.async.} =
|
||||||
debug "Raft Node sending Heart-Beat to peers", node_id=node.id
|
debug "Raft Node sending Heart-Beat to peers", node_id=node.id
|
||||||
|
@ -142,11 +142,11 @@ proc RaftNodeScheduleElectionTimeout*[SmCommandType, SmStateType](node: RaftNode
|
||||||
proc RaftNodeCancelAllTimers*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
proc RaftNodeCancelAllTimers*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
||||||
withRLock(node.raftStateMutex):
|
withRLock(node.raftStateMutex):
|
||||||
if node.heartBeatTimer != nil:
|
if node.heartBeatTimer != nil:
|
||||||
waitFor cancelAndWait(node.heartBeatTimer)
|
asyncSpawn cancelAndWait(node.heartBeatTimer)
|
||||||
if node.electionTimeoutTimer != nil:
|
if node.electionTimeoutTimer != nil:
|
||||||
waitFor cancelAndWait(node.electionTimeoutTimer )
|
asyncSpawn cancelAndWait(node.electionTimeoutTimer )
|
||||||
if node.appendEntriesTimer != nil:
|
if node.appendEntriesTimer != nil:
|
||||||
waitFor cancelAndWait(node.appendEntriesTimer)
|
asyncSpawn cancelAndWait(node.appendEntriesTimer)
|
||||||
|
|
||||||
proc RaftNodeStop*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
proc RaftNodeStop*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
|
||||||
# Try to stop gracefully
|
# Try to stop gracefully
|
||||||
|
|
|
@ -26,9 +26,9 @@ proc basicClusterMain*() =
|
||||||
test "Generate Random Client SmCommands Queue":
|
test "Generate Random Client SmCommands Queue":
|
||||||
discard
|
discard
|
||||||
|
|
||||||
test "Start Basic Raft Cluster And wait it to converge (Elect a Leader)":
|
test "Start Basic Raft Cluster And wait it to converge 10s (Elect a Leader)":
|
||||||
BasicRaftClusterStart(cluster)
|
BasicRaftClusterStart(cluster)
|
||||||
let dur = seconds(60)
|
let dur = seconds(10)
|
||||||
waitFor sleepAsync(dur)
|
waitFor sleepAsync(dur)
|
||||||
|
|
||||||
test "Simulate Basic Raft Cluster Client SmCommands Execution / Log Replication":
|
test "Simulate Basic Raft Cluster Client SmCommands Execution / Log Replication":
|
||||||
|
|
Loading…
Reference in New Issue