diff --git a/errors.toml b/errors.toml index 4777112b5b3..b6199698ec5 100644 --- a/errors.toml +++ b/errors.toml @@ -1,7 +1,7 @@ # AUTOGENERATED BY github.com/pingcap/errors/errdoc-gen # YOU CAN CHANGE THE 'description'/'workaround' FIELDS IF THEM ARE IMPROPER. -["ErrLoadKeyspaceGroupsRetryExhaustd"] +["ErrLoadKeyspaceGroupsRetryExhausted"] error = ''' load keyspace groups retry exhausted, %s ''' diff --git a/pkg/errs/errno.go b/pkg/errs/errno.go index 827ea513ee6..3a756e8000d 100644 --- a/pkg/errs/errno.go +++ b/pkg/errs/errno.go @@ -39,20 +39,20 @@ var ( // tso errors var ( - ErrSetLocalTSOConfig = errors.Normalize("set local tso config failed, %s", errors.RFCCodeText("PD:tso:ErrSetLocalTSOConfig")) - ErrGetAllocator = errors.Normalize("get allocator failed, %s", errors.RFCCodeText("PD:tso:ErrGetAllocator")) - ErrGetLocalAllocator = errors.Normalize("get local allocator failed, %s", errors.RFCCodeText("PD:tso:ErrGetLocalAllocator")) - ErrSyncMaxTS = errors.Normalize("sync max ts failed, %s", errors.RFCCodeText("PD:tso:ErrSyncMaxTS")) - ErrResetUserTimestamp = errors.Normalize("reset user timestamp failed, %s", errors.RFCCodeText("PD:tso:ErrResetUserTimestamp")) - ErrGenerateTimestamp = errors.Normalize("generate timestamp failed, %s", errors.RFCCodeText("PD:tso:ErrGenerateTimestamp")) - ErrLogicOverflow = errors.Normalize("logic part overflow", errors.RFCCodeText("PD:tso:ErrLogicOverflow")) - ErrProxyTSOTimeout = errors.Normalize("proxy tso timeout", errors.RFCCodeText("PD:tso:ErrProxyTSOTimeout")) - ErrKeyspaceGroupIDInvalid = errors.Normalize("the keyspace group id is invalid, %s", errors.RFCCodeText("PD:tso:ErrKeyspaceGroupIDInvalid")) - ErrGetAllocatorManager = errors.Normalize("get allocator manager failed, %s", errors.RFCCodeText("PD:tso:ErrGetAllocatorManager")) - ErrLoadKeyspaceGroupsTimeout = errors.Normalize("load keyspace groups timeout", errors.RFCCodeText("ErrLoadKeyspaceGroupsTimeout")) - ErrLoadKeyspaceGroupsTerminated = errors.Normalize("load keyspace groups terminated", errors.RFCCodeText("ErrLoadKeyspaceGroupsTerminated")) - ErrLoadKeyspaceGroupsRetryExhaustd = errors.Normalize("load keyspace groups retry exhausted, %s", errors.RFCCodeText("ErrLoadKeyspaceGroupsRetryExhaustd")) - ErrKeyspaceNotAssigned = errors.Normalize("the keyspace %d isn't assigned to any keyspace group", errors.RFCCodeText("PD:tso:ErrKeyspaceNotAssigned")) + ErrSetLocalTSOConfig = errors.Normalize("set local tso config failed, %s", errors.RFCCodeText("PD:tso:ErrSetLocalTSOConfig")) + ErrGetAllocator = errors.Normalize("get allocator failed, %s", errors.RFCCodeText("PD:tso:ErrGetAllocator")) + ErrGetLocalAllocator = errors.Normalize("get local allocator failed, %s", errors.RFCCodeText("PD:tso:ErrGetLocalAllocator")) + ErrSyncMaxTS = errors.Normalize("sync max ts failed, %s", errors.RFCCodeText("PD:tso:ErrSyncMaxTS")) + ErrResetUserTimestamp = errors.Normalize("reset user timestamp failed, %s", errors.RFCCodeText("PD:tso:ErrResetUserTimestamp")) + ErrGenerateTimestamp = errors.Normalize("generate timestamp failed, %s", errors.RFCCodeText("PD:tso:ErrGenerateTimestamp")) + ErrLogicOverflow = errors.Normalize("logic part overflow", errors.RFCCodeText("PD:tso:ErrLogicOverflow")) + ErrProxyTSOTimeout = errors.Normalize("proxy tso timeout", errors.RFCCodeText("PD:tso:ErrProxyTSOTimeout")) + ErrKeyspaceGroupIDInvalid = errors.Normalize("the keyspace group id is invalid, %s", errors.RFCCodeText("PD:tso:ErrKeyspaceGroupIDInvalid")) + ErrGetAllocatorManager = errors.Normalize("get allocator manager failed, %s", errors.RFCCodeText("PD:tso:ErrGetAllocatorManager")) + ErrLoadKeyspaceGroupsTimeout = errors.Normalize("load keyspace groups timeout", errors.RFCCodeText("ErrLoadKeyspaceGroupsTimeout")) + ErrLoadKeyspaceGroupsTerminated = errors.Normalize("load keyspace groups terminated", errors.RFCCodeText("ErrLoadKeyspaceGroupsTerminated")) + ErrLoadKeyspaceGroupsRetryExhausted = errors.Normalize("load keyspace groups retry exhausted, %s", errors.RFCCodeText("ErrLoadKeyspaceGroupsRetryExhausted")) + ErrKeyspaceNotAssigned = errors.Normalize("the keyspace %d isn't assigned to any keyspace group", errors.RFCCodeText("PD:tso:ErrKeyspaceNotAssigned")) ) // member errors diff --git a/pkg/keyspace/keyspace.go b/pkg/keyspace/keyspace.go index d3383a7cebf..6c052ad47dd 100644 --- a/pkg/keyspace/keyspace.go +++ b/pkg/keyspace/keyspace.go @@ -110,7 +110,7 @@ func (manager *Manager) Bootstrap() error { return err } now := time.Now().Unix() - defaultKeyspaceMata := &keyspacepb.KeyspaceMeta{ + defaultKeyspaceMeta := &keyspacepb.KeyspaceMeta{ Id: DefaultKeyspaceID, Name: DefaultKeyspaceName, State: keyspacepb.KeyspaceState_ENABLED, @@ -122,14 +122,14 @@ func (manager *Manager) Bootstrap() error { if err != nil { return err } - defaultKeyspaceMata.Config = config - err = manager.saveNewKeyspace(defaultKeyspaceMata) + defaultKeyspaceMeta.Config = config + err = manager.saveNewKeyspace(defaultKeyspaceMeta) // It's possible that default keyspace already exists in the storage (e.g. PD restart/recover), // so we ignore the keyspaceExists error. if err != nil && err != ErrKeyspaceExists { return err } - if err := manager.kgm.UpdateKeyspaceForGroup(endpoint.Basic, config[TSOKeyspaceGroupIDKey], defaultKeyspaceMata.GetId(), opAdd); err != nil { + if err := manager.kgm.UpdateKeyspaceForGroup(endpoint.Basic, config[TSOKeyspaceGroupIDKey], defaultKeyspaceMeta.GetId(), opAdd); err != nil { return err } // Initialize pre-alloc keyspace. diff --git a/pkg/tso/keyspace_group_manager.go b/pkg/tso/keyspace_group_manager.go index 57643b64ecc..506b36dff58 100644 --- a/pkg/tso/keyspace_group_manager.go +++ b/pkg/tso/keyspace_group_manager.go @@ -247,7 +247,7 @@ func (kgm *KeyspaceGroupManager) Initialize() error { // Initialize the default keyspace group if it isn't configured in the storage. if !defaultKGConfigured { keyspaces := []uint32{mcsutils.DefaultKeyspaceID} - kgm.initDefaultKeysapceGroup(keyspaces) + kgm.initDefaultKeyspaceGroup(keyspaces) } // Watch/apply keyspace group membership/distribution meta changes dynamically. @@ -287,7 +287,7 @@ func (kgm *KeyspaceGroupManager) checkInitProgress(ctx context.Context, cancel c <-done } -func (kgm *KeyspaceGroupManager) initDefaultKeysapceGroup(keyspaces []uint32) { +func (kgm *KeyspaceGroupManager) initDefaultKeyspaceGroup(keyspaces []uint32) { log.Info("initializing default keyspace group", zap.Int("keyspaces-length", len(keyspaces))) @@ -353,7 +353,7 @@ func (kgm *KeyspaceGroupManager) initAssignment( // If limit is 0, it will load all keyspace groups from the start ID. func (kgm *KeyspaceGroupManager) loadKeyspaceGroups( ctx context.Context, startID uint32, limit int64, -) (revison int64, ksgs []*endpoint.KeyspaceGroup, more bool, err error) { +) (revision int64, ksgs []*endpoint.KeyspaceGroup, more bool, err error) { rootPath := kgm.legacySvcRootPath startKey := strings.Join([]string{rootPath, endpoint.KeyspaceGroupIDPath(startID)}, "/") endKey := strings.Join( @@ -392,7 +392,7 @@ func (kgm *KeyspaceGroupManager) loadKeyspaceGroups( } if i == kgm.loadFromEtcdMaxRetryTimes { - return 0, []*endpoint.KeyspaceGroup{}, false, errs.ErrLoadKeyspaceGroupsRetryExhaustd.FastGenByArgs(err) + return 0, []*endpoint.KeyspaceGroup{}, false, errs.ErrLoadKeyspaceGroupsRetryExhausted.FastGenByArgs(err) } kgs := make([]*endpoint.KeyspaceGroup, 0, len(resp.Kvs)) @@ -405,10 +405,10 @@ func (kgm *KeyspaceGroupManager) loadKeyspaceGroups( } if resp.Header != nil { - revison = resp.Header.Revision + revision = resp.Header.Revision } - return revison, kgs, resp.More, nil + return revision, kgs, resp.More, nil } // startKeyspaceGroupsMetaWatchLoop Repeatedly watches any change in keyspace group membership/distribution @@ -473,7 +473,7 @@ func (kgm *KeyspaceGroupManager) watchKeyspaceGroupsMetaChange(revision int64) ( group := &endpoint.KeyspaceGroup{} if err := json.Unmarshal(event.Kv.Value, group); err != nil { log.Warn("failed to unmarshal keyspace group", - zap.Uint32("keysapce-group-id", groupID), + zap.Uint32("keyspace-group-id", groupID), zap.Error(errs.ErrJSONUnmarshal.Wrap(err).FastGenWithCause())) } kgm.updateKeyspaceGroup(group) @@ -483,7 +483,7 @@ func (kgm *KeyspaceGroupManager) watchKeyspaceGroupsMetaChange(revision int64) ( kgm.deleteKeyspaceGroup(groupID) log.Warn("removed default keyspace group meta config from the storage. " + "now every tso node/pod will initialize it") - kgm.initDefaultKeysapceGroup(keyspaces) + kgm.initDefaultKeyspaceGroup(keyspaces) } else { kgm.deleteKeyspaceGroup(groupID) } diff --git a/pkg/tso/tso.go b/pkg/tso/tso.go index d7bdf95ff65..523370cd677 100644 --- a/pkg/tso/tso.go +++ b/pkg/tso/tso.go @@ -168,7 +168,7 @@ func (t *timestampOracle) SyncTimestamp(leadership *election.Leadership) error { // If the current system time minus the saved etcd timestamp is less than `UpdateTimestampGuard`, // the timestamp allocation will start from the saved etcd timestamp temporarily. if typeutil.SubRealTimeByWallClock(next, last) < UpdateTimestampGuard { - log.Error("system time may be incorrect", + log.Warn("system time may be incorrect", zap.Time("last", last), zap.Time("next", next), errs.ZapError(errs.ErrIncorrectSystemTime)) next = last.Add(UpdateTimestampGuard) }