pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.35k stars 5.85k forks source link

Duplicated definition or Non-normalized message of error code #27298

Open guo-shaoge opened 3 years ago

guo-shaoge commented 3 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

cd $working_dir/tidb && tools/check/check-errdoc.sh

2. What did you expect to see? (Required)

Generate successfully

3. What did you see instead (Required)

Generate successfully, output:
Duplicated error code: ddl:8200
Duplicated error code: ddl:8200
Duplicated error code: ddl:8200
Duplicated error code: ddl:8200
Non-normalized error: scan break error
Duplicated error code: types:1292
Non-normalized error: can not add because sorted
Duplicated error code: ddl:1273
Non-normalized error: insert statement not found
Non-normalized error: proto: negative length found during unmarshaling
Non-normalized error: proto: integer overflow
Non-normalized error: proto: unexpected end of group
Non-normalized error: label constraint should be in format '{+|-}key=value'
Non-normalized error: unsupported label constraint
Non-normalized error: conflicting label constraints
Non-normalized error: label constraints in map syntax have invalid replicas
Non-normalized error: invalid label constraints format
Non-normalized error: label constraints with invalid REPLICAS
Non-normalized error: invalid bundle ID
Non-normalized error: invalid bundle ID format
Non-normalized error: REPLICAS must be 1 if ROLE=leader
Non-normalized error: the ROLE field is not specified
Non-normalized error: no rule of such role to drop
Duplicated error code: planner:8108
Non-normalized error: retryable: lock not found
Non-normalized error: retryable: already rollback
Non-normalized error: retryable: replaced by another transaction
Duplicated error code: planner:1046
Non-normalized error: Pattern not match
Non-normalized error: invalid syntax

4. What is your TiDB version? (Required)

master

guo-shaoge commented 3 years ago

As the output said, we have some minor mistakes when defining error code:

  1. Non-normalized error: such as ErrPatternNotMatch, which didn't use dbterror.ClassOptimizer.NewStd() to define it.
  2. Duplicated error: such as ErrNoDB, which defined in multiple package(plannercore and expression).

Also we need to fix tools/check/check-errdoc.sh to let CI detect this situation.

Defined2014 commented 10 months ago

Do we still need check-errdoc.sh now? Seems we exists a lot of duplicate error code now and it's not easy to fix.