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

*: normalize error according errdoc-gen #7114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
254 changes: 207 additions & 47 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@ error = '''
watcher canceled
'''

["PD:etcd:ErrExceedMaxEtcdTxnOps"]
error = '''
exceed max etcd txn operations
'''

["PD:etcd:ErrIllegalOperation"]
error = '''
unknown operation
'''

["PD:etcd:ErrNewEtcdClient"]
error = '''
new etcd client failed
Expand Down Expand Up @@ -471,6 +481,136 @@ error = '''
failed to unmarshal json
'''

["PD:keyspace:ErrKeyspaceExists"]
error = '''
keyspace already exists
'''

["PD:keyspace:ErrKeyspaceNotAssigned"]
error = '''
the keyspace %d isn't assigned to any keyspace group
'''

["PD:keyspace:ErrKeyspaceNotFound"]
error = '''
keyspace does not exist
'''

["PD:keyspace:ErrKeyspaceNotInAnyKeyspaceGroup"]
error = '''
keyspace is not in any keyspace group
'''

["PD:keyspace:ErrKeyspaceNotInKeyspaceGroup"]
error = '''
keyspace is not in this keyspace group
'''

["PD:keyspace:ErrKeyspaceUpdateNotAllowed"]
error = '''
cannot update keyspace that's %s
'''

["PD:keyspace:ErrModifyDefaultKeyspace"]
error = '''
cannot modify default keyspace's state
'''

["PD:keyspacegroup:ErrDefaultKeyspaceGroupNotFound"]
error = '''
default keyspace group not found
'''

["PD:keyspacegroup:ErrKeyspaceGroupExists"]
error = '''
keyspace group already exists
'''

["PD:keyspacegroup:ErrKeyspaceGroupIDInvalid"]
error = '''
the keyspace group id is invalid, %s
'''

["PD:keyspacegroup:ErrKeyspaceGroupInMerging"]
error = '''
keyspace group %v is in merging state
'''

["PD:keyspacegroup:ErrKeyspaceGroupInSplit"]
error = '''
keyspace group %v is in split state
'''

["PD:keyspacegroup:ErrKeyspaceGroupIsMerging"]
error = '''
the keyspace group %d is merging
'''

["PD:keyspacegroup:ErrKeyspaceGroupNotEnoughReplicas"]
error = '''
not enough replicas in the keyspace group
'''

["PD:keyspacegroup:ErrKeyspaceGroupNotExists"]
error = '''
keyspace group %v does not exist
'''

["PD:keyspacegroup:ErrKeyspaceGroupNotInMerging"]
error = '''
keyspace group %v is not in merging state
'''

["PD:keyspacegroup:ErrKeyspaceGroupNotInSplit"]
error = '''
keyspace group %v is not in split state
'''

["PD:keyspacegroup:ErrKeyspaceGroupNotInitialized"]
error = '''
the keyspace group %d isn't initialized
'''

["PD:keyspacegroup:ErrKeyspaceGroupPrimaryNotFound"]
error = '''
primary of keyspace group does not exist
'''

["PD:keyspacegroup:ErrKeyspaceGroupWithEmptyKeyspace"]
error = '''
keyspace group with empty keyspace
'''

["PD:keyspacegroup:ErrLoadKeyspaceGroupsRetryExhausted"]
error = '''
load keyspace groups retry exhausted, %s
'''

["PD:keyspacegroup:ErrLoadKeyspaceGroupsTerminated"]
error = '''
load keyspace groups terminated
'''

["PD:keyspacegroup:ErrLoadKeyspaceGroupsTimeout"]
error = '''
load keyspace groups timeout
'''

["PD:keyspacegroup:ErrModifyDefaultKeyspaceGroup"]
error = '''
default keyspace group cannot be modified
'''

["PD:keyspacegroup:ErrNoAvailableNode"]
error = '''
no available node for keyspace group
'''

["PD:keyspacegroup:ErrNodeNotInKeyspaceGroup"]
error = '''
the tso node is not in this keyspace group
'''

["PD:leveldb:ErrLevelDBClose"]
error = '''
close leveldb error
Expand Down Expand Up @@ -531,21 +671,6 @@ error = '''
plugin is not found: %s
'''

["PD:operator:ErrRegionAbnormalPeer"]
error = '''
region %v has abnormal peer
'''

["PD:operator:ErrRegionNotAdjacent"]
error = '''
two regions are not adjacent
'''

["PD:operator:ErrRegionNotFound"]
error = '''
region %v not found
'''

["PD:os:ErrOSOpen"]
error = '''
open error
Expand Down Expand Up @@ -616,6 +741,21 @@ error = '''
failed to unmarshal proto
'''

["PD:region:ErrRegionAbnormalPeer"]
error = '''
region %v has abnormal peer
'''

["PD:region:ErrRegionNotAdjacent"]
error = '''
two regions are not adjacent
'''

["PD:region:ErrRegionNotFound"]
error = '''
region %v not found
'''

["PD:region:ErrRegionRuleContent"]
error = '''
invalid region rule content, %s
Expand All @@ -626,6 +766,21 @@ error = '''
region label rule not found for id %s
'''

["PD:region:ErrRegionSplitFailed"]
error = '''
region split failed
'''

["PD:region:ErrRegionSplitTimeout"]
error = '''
region split timeout
'''

["PD:region:ErrRegionStale"]
error = '''
region is stale: region %v origin %v
'''

["PD:resourcemanager:ErrDeleteReservedGroup"]
error = '''
cannot delete reserved group
Expand Down Expand Up @@ -726,24 +881,44 @@ error = '''
client url empty
'''

["PD:server:ErrClusterMismatched"]
error = '''
rpc error: code = Unavailable desc = cluster mismatched
'''

["PD:server:ErrConfiguration"]
error = '''
cannot set invalid configuration
'''

["PD:server:ErrEtcdNotStarted"]
error = '''
rpc error: code = Unavailable desc = server is started, but etcd not started
'''

["PD:server:ErrLeaderNil"]
error = '''
leader is nil
'''

["PD:server:ErrNotLeader"]
error = '''
rpc error: code = Unavailable desc = not leader
'''

["PD:server:ErrRateLimitExceeded"]
error = '''
rate limit exceeded
'''

["PD:server:ErrSendHeartbeatTimeout"]
error = '''
rpc error: code = DeadlineExceeded desc = send heartbeat timeout
'''

["PD:server:ErrServerNotStarted"]
error = '''
server not started
rpc error: code = Unavailable desc = server not started
'''

["PD:server:ErrServiceRegistered"]
Expand Down Expand Up @@ -771,6 +946,11 @@ error = '''
parse uint error
'''

["PD:tso:ErrForwardTSOTimeout"]
error = '''
rpc error: code = DeadlineExceeded desc = forward tso request timeout
'''

["PD:tso:ErrGenerateTimestamp"]
error = '''
generate timestamp failed, %s
Expand All @@ -796,44 +976,19 @@ error = '''
get min ts failed, %s
'''

["PD:tso:ErrKeyspaceGroupIDInvalid"]
error = '''
the keyspace group id is invalid, %s
'''

["PD:tso:ErrKeyspaceGroupIsMerging"]
error = '''
the keyspace group %d is merging
'''

["PD:tso:ErrKeyspaceGroupNotInitialized"]
error = '''
the keyspace group %d isn't initialized
'''

["PD:tso:ErrKeyspaceNotAssigned"]
error = '''
the keyspace %d isn't assigned to any keyspace group
'''

["PD:tso:ErrLoadKeyspaceGroupsRetryExhausted"]
error = '''
load keyspace groups retry exhausted, %s
'''

["PD:tso:ErrLoadKeyspaceGroupsTerminated"]
["PD:tso:ErrLogicOverflow"]
error = '''
load keyspace groups terminated
logic part overflow
'''

["PD:tso:ErrLoadKeyspaceGroupsTimeout"]
["PD:tso:ErrMaxCountTSOProxyRoutinesExceeded"]
error = '''
load keyspace groups timeout
rpc error: code = ResourceExhausted desc = max count of concurrent tso proxy routines exceeded
'''

["PD:tso:ErrLogicOverflow"]
["PD:tso:ErrNotFoundTSOAddr"]
error = '''
logic part overflow
rpc error: code = NotFound desc = not found tso address
'''

["PD:tso:ErrProxyTSOTimeout"]
Expand All @@ -856,6 +1011,11 @@ error = '''
sync max ts failed, %s
'''

["PD:tso:ErrTSOProxyRecvFromClientTimeout"]
error = '''
rpc error: code = DeadlineExceeded desc = tso proxy timeout when receiving from client; stream closed by server
'''

["PD:tso:ErrUpdateTimestamp"]
error = '''
update timestamp failed, %s
Expand Down
10 changes: 2 additions & 8 deletions pkg/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/docker/go-units"
"github.com/gogo/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/kvproto/pkg/replication_modepb"
Expand All @@ -41,11 +40,6 @@ import (

const randomRegionMaxRetry = 10

// errRegionIsStale is error info for region is stale.
func errRegionIsStale(region *metapb.Region, origin *metapb.Region) error {
return errors.Errorf("region is stale: region %v origin %v", region, origin)
}

// RegionInfo records detail region info.
// the properties are Read-Only once created except buckets.
// the `buckets` could be modified by the request `report buckets` with greater version.
Expand Down Expand Up @@ -889,7 +883,7 @@ func check(region, origin *RegionInfo, overlaps []*regionItem) error {
for _, item := range overlaps {
// PD ignores stale regions' heartbeats, unless it is recreated recently by unsafe recover operation.
if region.GetRegionEpoch().GetVersion() < item.GetRegionEpoch().GetVersion() && !region.isRegionRecreated() {
return errRegionIsStale(region.GetMeta(), item.GetMeta())
return errs.ErrRegionStale.FastGenByArgs(region.GetMeta(), item.GetMeta())
}
}
if origin == nil {
Expand All @@ -902,7 +896,7 @@ func check(region, origin *RegionInfo, overlaps []*regionItem) error {
isTermBehind := region.GetTerm() > 0 && region.GetTerm() < origin.GetTerm()
// Region meta is stale, return an error.
if (isTermBehind || r.GetVersion() < o.GetVersion() || r.GetConfVer() < o.GetConfVer()) && !region.isRegionRecreated() {
return errRegionIsStale(region.GetMeta(), origin.GetMeta())
return errs.ErrRegionStale.FastGenByArgs(region.GetMeta(), origin.GetMeta())
}

return nil
Expand Down
Loading
Loading