-
Notifications
You must be signed in to change notification settings - Fork 198
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
sync-diff-inspector: skip validation for tables that exist only upstream or downstream and print skipped information in summary and progress #693
Conversation
[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. |
/run-all-tests |
/cc @lichunzhu |
sync_diff_inspector/source/source.go
Outdated
func AllTableExist(tableDiffs *common.TableDiff) bool { | ||
if tableDiffs.NeedSkippedTable == common.AllTableExistFlag { | ||
return true | ||
} | ||
return false | ||
} |
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.
func AllTableExist(tableDiffs *common.TableDiff) bool { | |
if tableDiffs.NeedSkippedTable == common.AllTableExistFlag { | |
return true | |
} | |
return false | |
} | |
func AllTableExist(needSkipTable int) bool { | |
return tableDiffs.NeedSkippedTable == common.AllTableExistFlag | |
} |
sync_diff_inspector/diff.go
Outdated
var isEqual, isSkip bool | ||
isAllTableExist := tables[tableIndex].NeedSkippedTable | ||
if source.AllTableExist(tables[tableIndex]) { | ||
var err error | ||
isEqual, isSkip, err = df.compareStruct(ctx, tableIndex) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
} else { | ||
isEqual, isSkip = false, true | ||
} |
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.
var isEqual, isSkip bool | |
isAllTableExist := tables[tableIndex].NeedSkippedTable | |
if source.AllTableExist(tables[tableIndex]) { | |
var err error | |
isEqual, isSkip, err = df.compareStruct(ctx, tableIndex) | |
if err != nil { | |
return errors.Trace(err) | |
} | |
} else { | |
isEqual, isSkip = false, true | |
} | |
isEqual, isSkip, isAllTableExist := false, true, tables[tableIndex].NeedSkippedTable | |
if source.AllTableExist(tables[tableIndex]) { | |
var err error | |
isEqual, isSkip, err = df.compareStruct(ctx, tableIndex) | |
if err != nil { | |
return errors.Trace(err) | |
} | |
} |
@@ -24,12 +24,12 @@ import ( | |||
|
|||
func TestProgress(t *testing.T) { | |||
p := NewTableProgressPrinter(4, 0) | |||
p.RegisterTable("1", true, true) | |||
p.RegisterTable("1", true, true, 1) |
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.
Use constant instead of 1
0
.
sync_diff_inspector/report/report.go
Outdated
ChunkMap map[string]*ChunkResult `json:"chunk-result"` // `ChunkMap` stores the `ChunkResult` of each chunk of the table | ||
UpCount int64 `json:"up-count"` // `UpCount` is the number of rows in the table from upstream | ||
DownCount int64 `json:"down-count"` // `DownCount` is the number of rows in the table from downstream | ||
TableSkipped int `json:"table-skipped"` |
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.
Maybe TableLack
to differ from DataSkip
@@ -104,7 +110,7 @@ func TestReport(t *testing.T) { | |||
report.CalculateTotalSize(ctx, db) | |||
|
|||
// Test Table Report | |||
report.SetTableStructCheckResult("test", "tbl", true, false) | |||
report.SetTableStructCheckResult("test", "tbl", true, false, 0) |
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.
ditto
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.
Rest LGTM
sync_diff_inspector/diff.go
Outdated
if rangeInfo.ChunkRange.Type == chunk.Empty { | ||
dml.node.State = checkpoints.IgnoreState | ||
// for tables that don't exist upstream or downstream | ||
if !source.AllTableExist(tableDiff) { | ||
upCount, _ := dbutil.GetRowCount(ctx, df.upstream.GetDB(), schema, table, "", nil) |
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 if upstream has multiple mysql sources?
if isExist == common.UpstreamTableLackFlag { | ||
state = TABLE_STATE_NOT_EXSIT_UPSTREAM | TABLE_STATE_REGISTER | ||
} else if isExist == common.DownstreamTableLackFlag { | ||
state = TABLE_STATE_NOT_EXSIT_DOWNSTREAM | TABLE_STATE_REGISTER | ||
} else { | ||
state = TABLE_STATE_RESULT_FAIL_STRUCTURE_DONE | TABLE_STATE_REGISTER | ||
} |
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.
if isExist == common.UpstreamTableLackFlag { | |
state = TABLE_STATE_NOT_EXSIT_UPSTREAM | TABLE_STATE_REGISTER | |
} else if isExist == common.DownstreamTableLackFlag { | |
state = TABLE_STATE_NOT_EXSIT_DOWNSTREAM | TABLE_STATE_REGISTER | |
} else { | |
state = TABLE_STATE_RESULT_FAIL_STRUCTURE_DONE | TABLE_STATE_REGISTER | |
} | |
switch isExist { | |
case common.UpstreamTableLackFlag: | |
state = TABLE_STATE_NOT_EXSIT_UPSTREAM | TABLE_STATE_REGISTER | |
case common.DownstreamTableLackFlag: | |
state = TABLE_STATE_NOT_EXSIT_DOWNSTREAM | TABLE_STATE_REGISTER | |
default: | |
state = TABLE_STATE_RESULT_FAIL_STRUCTURE_DONE | TABLE_STATE_REGISTER | |
} |
sync_diff_inspector/diff.go
Outdated
isEqual, isSkip, isAllTableExist := false, true, tables[tableIndex].NeedSkippedTable | ||
if source.AllTableExist(tables[tableIndex]) { | ||
isEqual, isSkip, isAllTableExist := false, true, tables[tableIndex].TableLack | ||
if common.AllTableExist(tables[tableIndex].TableLack) { |
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.
if common.AllTableExist(tables[tableIndex].TableLack) { | |
if common.AllTableExist(isAllTableExist) { |
sync_diff_inspector/diff.go
Outdated
upCount := df.upstream.GetCountAndCrc32(ctx, rangeInfo).Count | ||
downCount := df.downstream.GetCountAndCrc32(ctx, rangeInfo).Count |
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 only need count here. However, this function will also compute checksum. I'm afraid this will affect the efficiency.
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.
Got it. I defined a new interface GetCountForLackTable
in the next commit(34293bb).
var count int64 | ||
if matchSources != nil { | ||
for _, ms := range matchSources { | ||
count, err = dbutil.GetRowCount(ctx, ms.DBConn, ms.OriginSchema, ms.OriginTable, "", nil) |
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 error will be returned in ChecksumInfo
. Is that expected?
var isMatched bool | ||
// get all tables from all source db instance | ||
if f.MatchTable(targetSchema, targetTable) { |
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.
var isMatched bool | |
// get all tables from all source db instance | |
if f.MatchTable(targetSchema, targetTable) { | |
isMatched := f.MatchTable(targetSchema, targetTable) | |
if isMatched { |
sync_diff_inspector/source/tidb.go
Outdated
var isMatched bool | ||
if f.MatchTable(targetSchema, targetTable) { | ||
// if match the filter, we should respect it and check target has this table later. | ||
sourceTablesAfterRoute[uniqueId] = struct{}{} | ||
isMatched = true | ||
} |
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.
ditto
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.
Modified.
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.
LGTM
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 8d7c343
|
@liumengya94: Your PR was out of date, I have automatically updated it for you. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/run-unit-test |
What problem does this PR solve?
Issue Number: ref #692
What is changed and how it works?
skip-non-existing-table
, which defaults to false.summary.txt
.Check List
Tests
Code changes
Side effects
Related changes