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:
Hitoshi Mitake 2016-04-22 23:39:08 +09:00
parent 69bc0f76bc
commit 24077fb3f6

View File

@ -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