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

mysql.go: data may not consistent when no pk but has uk #421

Merged
merged 5 commits into from
Dec 24, 2018

Conversation

july2993
Copy link
Contributor

What problem does this PR solve?

see https://internal.pingcap.net/jira/browse/TOOL-714
mysql.go: data may not consistent when no pk but has uk

cause by drainer using uk as where to update (where a1 = * and a3 is
NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null

What is changed and how it works?

choose pk first, and check all column not null if use unique key, or use all columns

Check List

Tests

  • Integration test

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch
    kafka branch

cause by drainer using uk as where to update (where a1 = * and a3 is
	NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null
@july2993
Copy link
Contributor Author

/run-integration-test

@IANTHEREAL
Copy link
Collaborator

if we have multiple unique indices, we chose any one but it contains null column, maybe it's better to chose another one, do you read code in syncer https://github.com/pingcap/tidb-enterprise-tools/blob/dm-master/syncer/dml.go?

@july2993
Copy link
Contributor Author

/run-all-tests

@july2993
Copy link
Contributor Author

/run-all-tests

@july2993
Copy link
Contributor Author

@GregoryIan PTAL

@july2993
Copy link
Contributor Author

/run-all-tests

@IANTHEREAL
Copy link
Collaborator

please fix ci

@IANTHEREAL
Copy link
Collaborator

LGTM

@WangXiangUSTC
Copy link
Contributor

/run-all-tests

}

columns := make(map[string]*model.ColumnInfo)
for _, col := range table.Columns {
columns[col.Name.O] = col
}

for _, idx := range table.Indices {
// put primary key at [0], so we get primary key first if table has primary key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code seems can delete, it may make some confuse

@july2993
Copy link
Contributor Author

/run-all-tests

@july2993
Copy link
Contributor Author

/run-integration-test

@july2993
Copy link
Contributor Author

/run-integration-test

Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@july2993 july2993 merged commit 20b3e2a into master Dec 24, 2018
@july2993 july2993 deleted the hjh/fix_null_uk branch December 24, 2018 05:03
july2993 added a commit that referenced this pull request Dec 25, 2018
* mysql.go: data may not consistent when no pk but has uk

cause by drainer using uk as where to update (where a1 = * and a3 is
	NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null
july2993 added a commit that referenced this pull request Dec 27, 2018
* mysql.go: data may not consistent when no pk but has uk

cause by drainer using uk as where to update (where a1 = * and a3 is
	NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null
july2993 added a commit that referenced this pull request Dec 27, 2018
* mysql.go: data may not consistent when no pk but has uk

cause by drainer using uk as where to update (where a1 = * and a3 is
	NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null
WangXiangUSTC pushed a commit that referenced this pull request Jan 21, 2019
* mysql.go: data may not consistent when no pk but has uk

cause by drainer using uk as where to update (where a1 = * and a3 is
	NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null
WangXiangUSTC added a commit that referenced this pull request Jan 22, 2019
* mysql.go: data may not consistent when no pk but has uk

cause by drainer using uk as where to update (where a1 = * and a3 is
	NULL), may update the wrong row
when any column is null, it will not be index, so we can't use it unless
all column of index is not null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants