Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tso: add retry for UpdateTSO #9021

Merged
merged 5 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkg/tso/global_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,21 @@ func (gta *GlobalTSOAllocator) IsInitialize() bool {
}

// UpdateTSO is used to update the TSO in memory and the time window in etcd.
func (gta *GlobalTSOAllocator) UpdateTSO() error {
return gta.timestampOracle.UpdateTimestamp()
func (gta *GlobalTSOAllocator) UpdateTSO() (err error) {
// When meet network partition, we need to manually retry to update the global tso,
// next request succeeds with the new endpoint, according to https://github.com/etcd-io/etcd/issues/8711
maxRetryCount := 3
for range maxRetryCount {
err = gta.timestampOracle.UpdateTimestamp()
if err == nil {
return nil
}
log.Warn("try to update the global tso but failed", errs.ZapError(err))
// Etcd client retry with roundRobinQuorumBackoff https://github.com/etcd-io/etcd/blob/d62cdeee4863001b09e772ed013eb1342a1d0f89/client/v3/client.go#L488
// And its default interval is 25ms, so we sleep 50ms here. https://github.com/etcd-io/etcd/blob/d62cdeee4863001b09e772ed013eb1342a1d0f89/client/v3/options.go#L53
time.Sleep(50 * time.Millisecond)
}
return
}

// SetTSO sets the physical part with given TSO.
Expand Down