lni / dragonboat

A feature complete and high performance multi-group Raft library in Go.
Apache License 2.0
4.99k stars 534 forks source link

LeaderTransfer does‘t work due to prevote #223

Closed enefuture closed 2 years ago

enefuture commented 2 years ago

Note: for reported bugs, please fill in the following details. bug reports without detailed steps on how to reproduce will be automatically closed.

Dragonboat version

master

Expected behavior

LeaderTransfer can change node role from follower to leader

Actual behavior

open prevote,LeaderTransfer does not work, do nothing with call LeaderTransfer

Steps to reproduce the behavior

follower node need to LeaderTransfer log: 2022-01-10 17:17:20.290847 I | 20989 internal/raft/raft.go:2157 [f:12093922,l:17277407,t:9,c:17277407,a:17277407] [00127:00001] t9 TimeoutNow received 2022-01-10 17:17:20.290924 W | 20989 internal/raft/raft.go:1004 [f:12093922,l:17277407,t:9,c:17277407,a:17277407] [00127:00001] t9 became PreVote candidate 2022-01-10 17:17:20.290944 W | 20989 internal/raft/raft.go:1121 [f:12093922,l:17277407,t:9,c:17277407,a:17277407] [00127:00001] t9 received RequestPreVoteResp from n00001 2022-01-10 17:17:20.290964 W | 20989 internal/raft/raft.go:1158 [f:12093922,l:17277407,t:9,c:17277407,a:17277407] [00127:00001] t9 sent RequestPreVote to n00002 2022-01-10 17:17:20.290979 W | 20989 internal/raft/raft.go:1158 [f:12093922,l:17277407,t:9,c:17277407,a:17277407] [00127:00001] t9 sent RequestPreVote to n00003 2022-01-10 17:17:20.364358 I | 20989 internal/raft/raft.go:956 [f:12093922,l:17277407,t:9,c:17277407,a:17277407] [00127:00001] t9 became follower

master node log: 2022-01-10 17:17:20.291170 W | 21000 internal/raft/raft.go:1538 [f:13982923,l:17277407,t:9,c:17277407,a:17277407] [00127:00002] t9 dropped RequestVote at term 10 from n00001, msg type :RequestPreVote, leader available 2022-01-10 17:17:20.291259 I | 21000 internal/raft/raft.go:1599 [f:13982923,l:17277407,t:9,c:17277407,a:17277407] [00127:00002] t9 dropped RequestPreVote from n00001, term 10, term not matched

follower node log: 2022-01-10 17:17:20.295535 W | 21017 internal/raft/raft.go:1538 [f:12000048,l:17277407,t:9,c:17277407,a:17277407] [00127:00003] t9 dropped RequestVote at term 10 from n00001, msg type :RequestPreVote, leader available 2022-01-10 17:17:20.295599 I | 21017 internal/raft/raft.go:1599 [f:12000048,l:17277407,t:9,c:17277407,a:17277407] [00127:00003] t9 dropped RequestPreVote from n00001, term 10, term not matched

lni commented 2 years ago

I will have a look at this issue during this weekend

lni commented 2 years ago

@enefuture thanks for reporting the bug, it has been fixed in the master branch.