-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: Improve errors for mutation checker #30434
*: Improve errors for mutation checker #30434
Conversation
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
/run-check_dev |
Signed-off-by: ekexium <[email protected]>
d8c9a99
to
3dd63d1
Compare
/run-check_dev |
table/tables/mutation_checker.go
Outdated
@@ -295,6 +302,7 @@ func collectTableMutationsFromBufferStage(t *TableCommon, memBuffer kv.MemBuffer | |||
// Returns error if the index data is not a subset of the input data. | |||
func compareIndexData( | |||
sc *stmtctx.StatementContext, cols []*table.Column, indexData, input []types.Datum, indexInfo *model.IndexInfo, | |||
tableName string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could pass table info directly as something related to the table could be referenced in the future for example if we want to print out if it is partitioned table etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name is the only info we need at present, and it's easy to change the signature in the future if needed.
Anyway I've made this change. There's no big difference
Signed-off-by: ekexium <[email protected]>
@MyonKeminta PTAL |
table/tables/mutation_checker.go
Outdated
"inconsistent row mutation, row datum = {%v}, input datum = {%v}", decodedDatum.String(), | ||
inputDatum.String(), | ||
"inconsistent row mutation", zap.String("table", tableName), | ||
logutil2.Redact(zap.String("decoded datum", decodedDatum.String())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Redact
function looks like comes from BR and is not supposed to be used in code of TiDB's core. I thinks there should be another way to redact it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the table name should be redacted too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
Redact
function looks like comes from BR and is not supposed to be used in code of TiDB's core. I thinks there should be another way to redact it..
Totally agree. I think the problem is that BR and TiDB maintain their own logging utilities. Those in BR should be moved/merged to TiDB's, which should be another PR.
I tried but didn't find something convenient in TiDB for log redaction. If we want clean dependencies, I'm afraid we have to copy these utilities?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you confirm if this function's behavior can be controlled by TiDB's configuration? Or can you try to print the error object you created instead, which seem to have built-in redacting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you confirm if this function's behavior can be controlled by TiDB's configuration?
I think so. It's controlled by errors.RedactLogEnabled
. I had a manual test.
Or can you try to print the error object you created instead, which seem to have built-in redacting?
Sounds like a good idea.
@@ -1009,6 +1009,9 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{ | |||
ErrInvalidIncrementAndOffset: mysql.Message("Invalid auto_increment settings: auto_increment_increment: %d, auto_increment_offset: %d, both of them must be in range [1..65535]", nil), | |||
ErrDataInconsistentMismatchCount: mysql.Message("data inconsistency in table: %s, index: %s, index-count:%d != record-count:%d", nil), | |||
ErrDataInconsistentMismatchIndex: mysql.Message("data inconsistency in table: %s, index: %s, col: %s, handle: %#v, index-values:%#v != record-values:%#v, compare err:%#v", []int{3, 4, 5, 6}), | |||
ErrInconsistentRowValue: mysql.Message("writing inconsistent data in table: %s, expected-values:{%s} != record-values:{%s}", []int{1, 2}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be hard to say which is the expected one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a mistake here, the arguments are passed in the wrong order. But I think the input of the AddRecord
s should be the expected data?
Signed-off-by: ekexium <[email protected]>
Signed-off-by: ekexium <[email protected]>
/run-check_dev |
/run-check_dev |
1 similar comment
/run-check_dev |
8f169db
to
8c188b6
Compare
table/tables/mutation_checker.go
Outdated
"row handle = %v, index = %+v, row = %+v", | ||
indexHandle, insertionHandle, m, rowInsertion) | ||
err = ErrInconsistentHandle.GenWithStackByArgs(tableName, indexInfo.Name.O, indexHandle, insertionHandle, m, rowInsertion) | ||
logutil.BgLogger().Error(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider:
logutil.BgLogger().Error(err.Error()) | |
logutil.BgLogger().Error("inconsistent handles in row and index insertions detected", zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use zap.Error
to put the error to the log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the pattern that we always use. Usually the log message is a constant string and the other various information are provided in additional fields, wrapped with zap
which makes it lazy-evaluated.
Signed-off-by: ekexium <[email protected]>
The PR is based on #30310
What problem does this PR solve?
Issue Number: ref #26833
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note