Fix Cluster Test random hanging issue

This commit is contained in:
Raycho Mukelov 2023-09-07 06:56:35 +03:00
parent d11190bc5d
commit fba4ac836f
2 changed files with 6 additions and 6 deletions

View File

@ -118,7 +118,7 @@ template RaftTimerCreate(timerInterval: int, timerCallback: RaftTimerCallback):
# Timers scheduling stuff etc.
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.} =
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]) =
withRLock(node.raftStateMutex):
if node.heartBeatTimer != nil:
waitFor cancelAndWait(node.heartBeatTimer)
asyncSpawn cancelAndWait(node.heartBeatTimer)
if node.electionTimeoutTimer != nil:
waitFor cancelAndWait(node.electionTimeoutTimer )
asyncSpawn cancelAndWait(node.electionTimeoutTimer )
if node.appendEntriesTimer != nil:
waitFor cancelAndWait(node.appendEntriesTimer)
asyncSpawn cancelAndWait(node.appendEntriesTimer)
proc RaftNodeStop*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) =
# Try to stop gracefully

View File

@ -26,9 +26,9 @@ proc basicClusterMain*() =
test "Generate Random Client SmCommands Queue":
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)
let dur = seconds(60)
let dur = seconds(10)
waitFor sleepAsync(dur)
test "Simulate Basic Raft Cluster Client SmCommands Execution / Log Replication":