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

fix enlarged error redaction #52364

Closed
xhebox opened this issue Apr 7, 2024 · 0 comments · Fixed by #52359
Closed

fix enlarged error redaction #52364

xhebox opened this issue Apr 7, 2024 · 0 comments · Fixed by #52359
Labels

Comments

@xhebox
Copy link
Contributor

xhebox commented Apr 7, 2024

Bug Report

ref #51306

Errors of errStrForLog, handleAssertionFailure is already redacted, and we should not redact it again.

tidb/pkg/server/conn.go

Lines 1166 to 1181 in d2eb902

func errStrForLog(err error, redactMode string) string {
if redactMode == errors.RedactLogEnable {
// currently, only ErrParse is considered when enableRedactLog because it may contain sensitive information like
// password or accesskey
if parser.ErrParse.Equal(err) {
return "fail to parse SQL and can't redact when enable log redaction"
}
}
var ret string
if kv.ErrKeyExists.Equal(err) || parser.ErrParse.Equal(err) || infoschema.ErrTableNotExists.Equal(err) {
// Do not log stack for duplicated entry error.
ret = err.Error()
} else {
ret = errors.ErrorStack(err)
}
return redact.String(redactMode, ret)

1. Minimal reproduce step (Required)

mysql> create table t (a int, unique key (a));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t values (1),(1);
ERROR 1062 (23000): Duplicate entry '1' for key 'a'
mysql> set @@session.tidb_redact_log=1;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t values (1),(1);
ERROR 1062 (23000): Duplicate entry '?' for key '?'

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

[2024/04/07 11:09:34.014 +08:00] [INFO] [conn.go:1147] ["command dispatched failed"] [conn=2097154] [session_alias=] [connInfo="id:2097154, addr:[::1]:46506 status:10, collation:utf8mb4_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="insert into `t` values ( ‹1› ) , ( ‹1› )"] [txn_mode=PESSIMISTIC] [timestamp=448910950141526016] [err="[kv:1062]Duplicate entry '‹1›' for key 't.a'"]

3. What did you see instead (Required)

[2024/04/07 11:09:34.014 +08:00] [INFO] [conn.go:1147] ["command dispatched failed"] [conn=2097154] [session_alias=] [connInfo="id:2097154, addr:[::1]:46506 status:10, collation:utf8mb4_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="insert into `t` values ( ‹1› ) , ( ‹1› )"] [txn_mode=PESSIMISTIC] [timestamp=448910950141526016] [err="‹[kv:1062]Duplicate entry '‹‹1››' for key 't.a'›"]

4. What is your TiDB version? (Required)

master

@xhebox xhebox added type/bug This issue is a bug. sig/sql-infra SIG: SQL Infra affects-8.0 labels Apr 7, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in 8f985c7 Apr 7, 2024
@xhebox xhebox mentioned this issue Apr 7, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant