Skip to content

Commit

Permalink
etcdutil, leadership: avoid redundant created watch channel (tikv#7352)
Browse files Browse the repository at this point in the history
close tikv#7351

Signed-off-by: lhy1024 <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
lhy1024 and ti-chi-bot[bot] authored Nov 10, 2023
1 parent afe6afc commit da30175
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/election/leadership.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func (ls *Leadership) Watch(serverCtx context.Context, revision int64) {
continue
}
}
lastReceivedResponseTime = time.Now()
log.Info("watch channel is created", zap.Int64("revision", revision), zap.String("leader-key", ls.leaderKey), zap.String("purpose", ls.purpose))

watchChanLoop:
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ func (lw *LoopWatcher) watch(ctx context.Context, revision int64) (nextRevision
}()
ticker := time.NewTicker(RequestProgressInterval)
defer ticker.Stop()
lastReceivedResponseTime := time.Now()

for {
if watcherCancel != nil {
Expand Down Expand Up @@ -736,8 +735,10 @@ func (lw *LoopWatcher) watch(ctx context.Context, revision int64) (nextRevision
continue
}
}
lastReceivedResponseTime := time.Now()
log.Info("watch channel is created in watch loop",
zap.Int64("revision", revision), zap.String("name", lw.name), zap.String("key", lw.key))

watchChanLoop:
select {
case <-ctx.Done():
Expand Down

0 comments on commit da30175

Please sign in to comment.