From 38d1a5128fae2d049c299fc56ce8c2e8bd5772a1 Mon Sep 17 00:00:00 2001 From: qiuyesuifeng Date: Wed, 4 May 2016 11:22:30 +0800 Subject: [PATCH 1/2] server: add tso retry number log info. --- server/tso.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/tso.go b/server/tso.go index 2b3010178ea..ebdbb047282 100644 --- a/server/tso.go +++ b/server/tso.go @@ -147,7 +147,7 @@ func (s *Server) getRespTS() *pdpb.Timestamp { for i := 0; i < maxRetryNum; i++ { current, ok := s.ts.Load().(*atomicObject) if !ok { - log.Errorf("we haven't synced timestamp ok, wait and retry") + log.Errorf("we haven't synced timestamp ok, wait and retry, retry number %d", i) time.Sleep(200 * time.Millisecond) continue } @@ -155,7 +155,7 @@ func (s *Server) getRespTS() *pdpb.Timestamp { resp.Physical = proto.Int64(int64(current.physical.UnixNano()) / 1e6) resp.Logical = proto.Int64(atomic.AddInt64(¤t.logical, 1)) if *resp.Logical >= maxLogical { - log.Errorf("logical part outside of max logical interval %v, please check ntp time", resp) + log.Errorf("logical part outside of max logical interval %v, please check ntp time, retry number %d", resp, i) time.Sleep(50 * time.Millisecond) continue } From f531778903371cee63c247da9a3ab014a7e40a9a Mon Sep 17 00:00:00 2001 From: qiuyesuifeng Date: Wed, 4 May 2016 12:57:36 +0800 Subject: [PATCH 2/2] server: address comment. --- server/tso.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/tso.go b/server/tso.go index ebdbb047282..aa4e3eb72cb 100644 --- a/server/tso.go +++ b/server/tso.go @@ -140,14 +140,14 @@ func (s *Server) updateTimestamp() error { return nil } -const maxRetryNum = 100 +const maxRetryCount = 100 func (s *Server) getRespTS() *pdpb.Timestamp { resp := &pdpb.Timestamp{} - for i := 0; i < maxRetryNum; i++ { + for i := 0; i < maxRetryCount; i++ { current, ok := s.ts.Load().(*atomicObject) if !ok { - log.Errorf("we haven't synced timestamp ok, wait and retry, retry number %d", i) + log.Errorf("we haven't synced timestamp ok, wait and retry, retry count %d", i) time.Sleep(200 * time.Millisecond) continue } @@ -155,7 +155,7 @@ func (s *Server) getRespTS() *pdpb.Timestamp { resp.Physical = proto.Int64(int64(current.physical.UnixNano()) / 1e6) resp.Logical = proto.Int64(atomic.AddInt64(¤t.logical, 1)) if *resp.Logical >= maxLogical { - log.Errorf("logical part outside of max logical interval %v, please check ntp time, retry number %d", resp, i) + log.Errorf("logical part outside of max logical interval %v, please check ntp time, retry count %d", resp, i) time.Sleep(50 * time.Millisecond) continue }