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

Tikv inconsistent warning code and message with tidb #51882

Open
Tracked by #51876
yibin87 opened this issue Mar 19, 2024 · 4 comments
Open
Tracked by #51876

Tikv inconsistent warning code and message with tidb #51882

yibin87 opened this issue Mar 19, 2024 · 4 comments

Comments

@yibin87
Copy link
Contributor

yibin87 commented Mar 19, 2024

**Case1**
set tidb_opt_projection_push_down = 'on';
CREATE TABLE t1(a CHAR(1) CHARACTER SET utf8mb4);
INSERT INTO t1 VALUES('a');
SELECT CONCAT(a, x'ff') FROM t1;
--Expect
Error 3854 (HY000): Cannot convert string '\xFF' from binary to utf8mb4
--Actual
Error 1105 (HY000): Cannot convert string '\xFF' from binary to utf8mb4

**Case2**
set tidb_opt_projection_push_down = 'on';
CREATE TABLE t1(f1 LONGTEXT CHARACTER SET utf8mb4);
INSERT INTO t1 VALUES ('a');
SELECT @a:= CAST(f1 AS SIGNED) FROM t1
UNION ALL
SELECT CAST(f1 AS SIGNED) FROM t1;
--Expect
@a:= CAST(f1 AS SIGNED)
0
0
Level   Code    Message
Warning 1292    Truncated incorrect INTEGER value: 'a'
Warning 1292    Truncated incorrect INTEGER value: 'a'
--Actual
@a:= CAST(f1 AS SIGNED)
0
0
Level   Code    Message
Warning 1292    Truncated incorrect INTEGER value: 'a'
Warning 1292    evaluation failed: Truncated incorrect INTEGER value: 'a'```

### 1. What is your TiDB version? (Required)

<!-- Paste the output of SELECT tidb_version() -->
| Release Version: v7.4.0-alpha-2012-gfe01d11df6-dirty
Edition: Community
Git Commit Hash: https://github.com/pingcap/tidb/commit/fe01d11df67ca60573b028ed4c9bc52db9a17a7e
Git Branch: div_increase_prec
UTC Build Time: 2024-03-15 08:10:07
@yibin87
Copy link
Contributor Author

yibin87 commented Mar 19, 2024

/assign @yibin87

@aytrack aytrack added the sig/execution SIG execution label Mar 19, 2024
@yibin87
Copy link
Contributor Author

yibin87 commented May 24, 2024

The error code returned from tikv is further checked in tidb:

func getMySQLErrorCode(e *Error) uint16 {
rfcCode := e.RFCCode()
var class ErrClass
if index := strings.Index(string(rfcCode), ":"); index > 0 {
ec, has := rfcCode2errClass.Get(string(rfcCode)[:index])
if !has {
log.Warn("Unknown error class", zap.String("class", string(rfcCode)[:index]))
return defaultMySQLErrorCode
}
class = ec
}
codeMap, ok := ErrClassToMySQLCodes[class]
if !ok {
log.Warn("Unknown error class", zap.Int("class", int(class)))
return defaultMySQLErrorCode
}
_, ok = codeMap[ErrCode(e.Code())]
if !ok {
log.Debug("Unknown error code", zap.Int("class", int(class)), zap.Int("code", int(e.Code())))
return defaultMySQLErrorCode
}
return uint16(e.Code())
}

The RFCCode of tikv returned error looks like "tikv:3854". However, in tidb, "expression:3854" exists, while "tikv:3854" doesn't. Thus it is finally converted to tikv unknown error code(1105).

One way to quick fix this is to add one more check when tikv error's error code doesn't exist: check expression error code again. But it may lead to new problems:

  1. TiFlash also uses "tikv:xxxx" RFCCode, and the error codes in TiFlash are not all aligned with TiDB, which means TiFlash may reuse a tidb error code with different error meaning. If we force to check expression error code, we might provide a misleading error code instead of unknown error code(1105)
  2. Not sure if tikv's error codes are all aligned with TiDB. If not, we may provide misleading error code also.

Thus, we need to go through TiFlash/TiKV's error code to ensure they are all consistent with TiDB.

@yibin87
Copy link
Contributor Author

yibin87 commented May 24, 2024

/remove-type bug

@ti-chi-bot ti-chi-bot bot removed the type/bug This issue is a bug. label May 24, 2024
@yibin87
Copy link
Contributor Author

yibin87 commented May 24, 2024

/type enhancement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants