Skip to content

Commit

Permalink
tso: add retry for UpdateTSO
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 committed Jan 26, 2025
1 parent ae6df14 commit ea4f3f0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/tso/global_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,18 @@ 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
for i := 0; i < 3; i++ {

Check failure on line 146 in pkg/tso/global_allocator.go

View workflow job for this annotation

GitHub Actions / statics

for loop can be changed to use an integer range (Go 1.22+) (intrange)
err = gta.timestampOracle.UpdateTimestamp()
if err == nil {
return nil
}
log.Warn("try to update the global tso but failed", errs.ZapError(err))
time.Sleep(gta.am.updatePhysicalInterval)
}
return
}

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

0 comments on commit ea4f3f0

Please sign in to comment.