Skip to content

Commit

Permalink
Merge pull request #92 from pingcap/qiuyesuifeng/tso-log
Browse files Browse the repository at this point in the history
server: add tso retry number log info.
  • Loading branch information
qiuyesuifeng committed May 5, 2016
2 parents a038415 + f531778 commit c9722d0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/tso.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,22 @@ 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")
log.Errorf("we haven't synced timestamp ok, wait and retry, retry count %d", i)
time.Sleep(200 * time.Millisecond)
continue
}

resp.Physical = proto.Int64(int64(current.physical.UnixNano()) / 1e6)
resp.Logical = proto.Int64(atomic.AddInt64(&current.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 count %d", resp, i)
time.Sleep(50 * time.Millisecond)
continue
}
Expand Down

0 comments on commit c9722d0

Please sign in to comment.