From 7edb5b478576237d628abbb79f69789029d05bdf Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 29 Oct 2019 19:48:17 +0800 Subject: [PATCH 1/3] add log for get timestamps Signed-off-by: Ryan Leung --- server/grpc_service.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/grpc_service.go b/server/grpc_service.go index 29cf6b517ee..1d42b36c07d 100644 --- a/server/grpc_service.go +++ b/server/grpc_service.go @@ -87,6 +87,11 @@ func (s *Server) Tso(stream pdpb.PD_TsoServer) error { if err != nil { return status.Errorf(codes.Unknown, err.Error()) } + + elapsed := time.Since(start) + if elapsed > time.Second { + log.Warn("get timestamp too slow", zap.Duration("cost", elapsed)) + } response := &pdpb.TsoResponse{ Header: s.header(), Timestamp: &ts, From 0b2da0191b2820d656ac9580186dab1a769c87dd Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Wed, 30 Oct 2019 11:19:34 +0800 Subject: [PATCH 2/3] change to millisecond Signed-off-by: Ryan Leung --- server/grpc_service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/grpc_service.go b/server/grpc_service.go index 1d42b36c07d..bc277af0f62 100644 --- a/server/grpc_service.go +++ b/server/grpc_service.go @@ -89,7 +89,7 @@ func (s *Server) Tso(stream pdpb.PD_TsoServer) error { } elapsed := time.Since(start) - if elapsed > time.Second { + if elapsed > time.Millisecond { log.Warn("get timestamp too slow", zap.Duration("cost", elapsed)) } response := &pdpb.TsoResponse{ From e6b71b55c13c75565f52fe1535a5c768379335cf Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Wed, 30 Oct 2019 12:01:22 +0800 Subject: [PATCH 3/3] change threshold to 5ms Signed-off-by: Ryan Leung --- server/grpc_service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/grpc_service.go b/server/grpc_service.go index bc277af0f62..acad76d50b3 100644 --- a/server/grpc_service.go +++ b/server/grpc_service.go @@ -31,7 +31,7 @@ import ( "google.golang.org/grpc/status" ) -//revive:disable:unused-parameter +const slowThreshold = 5 * time.Millisecond // notLeaderError is returned when current server is not the leader and not possible to process request. // TODO: work as proxy. @@ -89,7 +89,7 @@ func (s *Server) Tso(stream pdpb.PD_TsoServer) error { } elapsed := time.Since(start) - if elapsed > time.Millisecond { + if elapsed > slowThreshold { log.Warn("get timestamp too slow", zap.Duration("cost", elapsed)) } response := &pdpb.TsoResponse{