Skip to content

Commit

Permalink
Revert the change to maxResetTSGap getter
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Apr 5, 2023
1 parent 1546758 commit 6870233
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/tso/allocator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ type AllocatorManager struct {
// in etcd, otherwise etcd will expire the leader key and other servers can campaign
// the primary/leader again. Etcd only supports seconds TTL, so here is second too.
leaderLease int64
maxResetTSGap time.Duration
maxResetTSGap func() time.Duration
securityConfig *grpcutil.TLSConfig
// for gRPC use
localAllocatorConn struct {
Expand Down Expand Up @@ -222,7 +222,7 @@ func NewAllocatorManager(
saveInterval: configProvider.GetTSOSaveInterval(),
updatePhysicalInterval: configProvider.GetTSOUpdatePhysicalInterval(),
leaderLease: configProvider.GetLeaderLease(),
maxResetTSGap: configProvider.GetMaxResetTSGap(),
maxResetTSGap: configProvider.GetMaxResetTSGap,
securityConfig: configProvider.GetTLSConfig(),
}
am.mu.allocatorGroups = make(map[string]*allocatorGroup)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestNewKeyspaceGroupManager(t *testing.T) {
re.False(am.enableLocalTSO)
re.Equal(utils.DefaultKeySpaceGroupID, am.ksgID)
re.Equal(utils.DefaultLeaderLease, am.leaderLease)
re.Equal(time.Hour*24, am.maxResetTSGap)
re.Equal(time.Hour*24, am.maxResetTSGap())
re.Equal(defaultKsgStorageTSRootPath, am.rootPath)
re.Equal(time.Duration(utils.DefaultLeaderLease)*time.Second, am.saveInterval)
re.Equal(time.Duration(50)*time.Millisecond, am.updatePhysicalInterval)
Expand Down
4 changes: 2 additions & 2 deletions pkg/tso/tso.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type timestampOracle struct {
// TODO: remove saveInterval
saveInterval time.Duration
updatePhysicalInterval time.Duration
maxResetTSGap time.Duration
maxResetTSGap func() time.Duration
// tso info stored in the memory
tsoMux *tsoObject
// last timestamp window stored in etcd
Expand Down Expand Up @@ -234,7 +234,7 @@ func (t *timestampOracle) resetUserTimestampInner(leadership *election.Leadershi
return errs.ErrResetUserTimestamp.FastGenByArgs("the specified counter is smaller than now")
}
// do not update if physical time is too greater than prev
if !skipUpperBoundCheck && physicalDifference >= t.maxResetTSGap.Milliseconds() {
if !skipUpperBoundCheck && physicalDifference >= t.maxResetTSGap().Milliseconds() {
tsoCounter.WithLabelValues("err_reset_large_ts", t.dcLocation).Inc()
return errs.ErrResetUserTimestamp.FastGenByArgs("the specified ts is too larger than now")
}
Expand Down

0 comments on commit 6870233

Please sign in to comment.