From c5510d616e2f41c33431e83d2c23d0cdfead80e8 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 12 Feb 2019 13:32:04 -0800 Subject: [PATCH] Remove delay for global statsz, bump RC version Signed-off-by: Derek Collison --- server/const.go | 2 +- server/events.go | 27 +-------------------------- server/events_test.go | 4 ++-- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/server/const.go b/server/const.go index 10524d24..16b8bab9 100644 --- a/server/const.go +++ b/server/const.go @@ -40,7 +40,7 @@ var ( const ( // VERSION is the current version for the server. - VERSION = "2.0.0-RC3" + VERSION = "2.0.0-RC4" // PROTO is the currently supported protocol. // 0 was the original diff --git a/server/events.go b/server/events.go index 195ef90c..03b2bf1a 100644 --- a/server/events.go +++ b/server/events.go @@ -16,7 +16,6 @@ package server import ( "encoding/json" "fmt" - "math/rand" "strconv" "strings" "sync" @@ -445,7 +444,7 @@ func (s *Server) initEventTracking() { s.Errorf("Error setting up internal tracking: %v", err) } // Listen for ping messages that will be sent to all servers for statsz. - if _, err := s.sysSubscribe(serverStatsPingReqSubj, s.statszPing); err != nil { + if _, err := s.sysSubscribe(serverStatsPingReqSubj, s.statszReq); err != nil { s.Errorf("Error setting up internal tracking: %v", err) } } @@ -572,30 +571,6 @@ func (s *Server) connsRequest(sub *subscription, subject, reply string, msg []by } } -// random back off interval for broadcast statsz ping requests. -const randomBackoff = 250 * time.Millisecond - -// statszPing will handle global requests for our server statsz. This will be a -// broadcast msg so we want to be mindful of that. We will do a random backoff and -// process in a separate go routine. -func (s *Server) statszPing(sub *subscription, subject, reply string, msg []byte) { - if !s.EventsEnabled() || reply == _EMPTY_ { - return - } - s.startGoRoutine(func() { - defer s.grWG.Done() - delay := time.Duration(rand.Intn(int(randomBackoff))) - select { - case <-time.After(delay): - s.mu.Lock() - defer s.mu.Unlock() - s.sendStatsz(reply) - case <-s.quitCh: - return - } - }) -} - // statszReq is a request for us to respond with current statz. func (s *Server) statszReq(sub *subscription, subject, reply string, msg []byte) { s.mu.Lock() diff --git a/server/events_test.go b/server/events_test.go index 449ad373..2343d3c5 100644 --- a/server/events_test.go +++ b/server/events_test.go @@ -1178,14 +1178,14 @@ func TestServerEventsPingStatsZ(t *testing.T) { m := ServerStatsMsg{} // Receive both manually. - msg, err := sub.NextMsg(randomBackoff * 2) + msg, err := sub.NextMsg(time.Second) if err != nil { t.Fatalf("Error receiving msg: %v", err) } if err := json.Unmarshal(msg.Data, &m); err != nil { t.Fatalf("Error unmarshalling the statz json: %v", err) } - msg, err = sub.NextMsg(randomBackoff) + msg, err = sub.NextMsg(time.Second) if err != nil { t.Fatalf("Error receiving msg: %v", err) }