Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 committed Apr 7, 2023
1 parent 742fb12 commit e9fb0f4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1759,12 +1759,13 @@ func (s *Server) startWatchServicePrimaryAddrLoop(serviceName string) {
return
default:
}
nextRevision, err := s.watchServicePrimaryAddr(ctx, serviceKey, revision)
nextRevision, err := s.watchServicePrimaryAddr(ctx, serviceName, revision)
if err != nil {
log.Error("watcher canceled unexpectedly and a new watcher will start after a while",
zap.Int64("next-revision", nextRevision),
zap.Time("retry-at", time.Now().Add(watchKEtcdChangeRetryInterval)),
zap.Error(err))
revision = nextRevision
time.Sleep(watchKEtcdChangeRetryInterval)
}
}
Expand All @@ -1777,7 +1778,10 @@ func (s *Server) watchServicePrimaryAddr(ctx context.Context, serviceName string

for {
watchChan := watcher.Watch(s.serverLoopCtx, serviceKey, clientv3.WithPrefix(), clientv3.WithRev(revision))
for wresp := range watchChan {
select {
case <-ctx.Done():
return revision, nil
case wresp := <-watchChan:
if wresp.CompactRevision != 0 {
log.Warn("required revision has been compacted, use the compact revision",
zap.Int64("required-revision", revision),
Expand Down Expand Up @@ -1813,11 +1817,6 @@ func (s *Server) watchServicePrimaryAddr(ctx context.Context, serviceName string
}
revision = wresp.Header.Revision
}
select {
case <-ctx.Done():
return revision, nil
default:
}
}
}

Expand Down

0 comments on commit e9fb0f4

Please sign in to comment.