mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: remove a data race of ServerStat
It seems that ServerStats.BecomeLeader() is missing a lock. Fix https://github.com/coreos/etcd/issues/5155
This commit is contained in:
parent
69bc0f76bc
commit
24077fb3f6
@ -142,6 +142,9 @@ func (ss *ServerStats) SendAppendReq(reqSize int) {
|
||||
}
|
||||
|
||||
func (ss *ServerStats) BecomeLeader() {
|
||||
ss.Lock()
|
||||
defer ss.Unlock()
|
||||
|
||||
if ss.State != raft.StateLeader {
|
||||
ss.State = raft.StateLeader
|
||||
ss.LeaderInfo.Name = ss.ID
|
||||
|
Loading…
x
Reference in New Issue
Block a user