Skip to content

Commit

Permalink
client: fix backoffer initialization (tikv#9012)
Browse files Browse the repository at this point in the history
ref tikv#8835, close tikv#9013

Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] authored Jan 22, 2025
1 parent 6cadbe7 commit 5a5c07e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/clients/tso/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (td *tsoDispatcher) handleDispatcher(wg *sync.WaitGroup) {
<-batchingTimer.C
defer batchingTimer.Stop()

bo := retry.InitialBackoffer(sd.UpdateMemberBackOffBaseTime, sd.UpdateMemberTimeout, sd.UpdateMemberBackOffBaseTime)
bo := retry.InitialBackoffer(sd.UpdateMemberBackOffBaseTime, sd.UpdateMemberMaxBackoffTime, sd.UpdateMemberTimeout)
tsoBatchLoop:
for {
select {
Expand Down
9 changes: 6 additions & 3 deletions client/servicediscovery/service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ import (
const (
// MemberUpdateInterval is the interval to update the member list.
MemberUpdateInterval = time.Minute
// UpdateMemberMaxBackoffTime is the max time to back off when updating the member list.
UpdateMemberMaxBackoffTime = 100 * time.Millisecond
// UpdateMemberBackOffBaseTime is the base time to back off when updating the member list.
// Here we use 20ms is because getting timestamp will print a warning log if the time exceeds 30ms.
UpdateMemberBackOffBaseTime = 20 * time.Millisecond
// UpdateMemberTimeout is the timeout to update the member list.
// Use a shorter timeout to recover faster from network isolation.
UpdateMemberTimeout = time.Second
// UpdateMemberBackOffBaseTime is the base time to back off when updating the member list.
UpdateMemberBackOffBaseTime = 100 * time.Millisecond

serviceModeUpdateInterval = 3 * time.Second
)
Expand Down Expand Up @@ -533,7 +536,7 @@ func (c *serviceDiscovery) updateMemberLoop() {
ticker := time.NewTicker(MemberUpdateInterval)
defer ticker.Stop()

bo := retry.InitialBackoffer(UpdateMemberBackOffBaseTime, UpdateMemberTimeout, UpdateMemberBackOffBaseTime)
bo := retry.InitialBackoffer(UpdateMemberBackOffBaseTime, UpdateMemberMaxBackoffTime, UpdateMemberTimeout)
for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 5a5c07e

Please sign in to comment.