Browse Source

Merge pull request #9562 from disksing/data-race

etcdserver/stats: fix stats data race.
Gyuho Lee 7 years ago
parent
commit
836fffa22a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      etcdserver/stats/server.go

+ 2 - 2
etcdserver/stats/server.go

@@ -74,10 +74,10 @@ type serverStats struct {
 func (ss *ServerStats) JSON() []byte {
 	ss.Lock()
 	stats := ss.serverStats
-	ss.Unlock()
-	stats.LeaderInfo.Uptime = time.Since(stats.LeaderInfo.StartTime).String()
 	stats.SendingPkgRate, stats.SendingBandwidthRate = stats.sendRateQueue.Rate()
 	stats.RecvingPkgRate, stats.RecvingBandwidthRate = stats.recvRateQueue.Rate()
+	stats.LeaderInfo.Uptime = time.Since(stats.LeaderInfo.StartTime).String()
+	ss.Unlock()
 	b, err := json.Marshal(stats)
 	// TODO(jonboulle): appropriate error handling?
 	if err != nil {