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

executor: add a variable to control whether we can write _tidb_rowid #8126

Merged
merged 4 commits into from
Nov 5, 2018

Conversation

zimulala
Copy link
Contributor

@zimulala zimulala commented Oct 31, 2018

What problem does this PR solve?

There are problems handling the following case:

create table tt(id binary(10), c int, primary key(id));
insert tt values (1, 10);
insert into tt (id, c, _tidb_rowid) values(30000,10,1);
tidb> select * from tt use index(`primary`);
+------------+------+
| id         | c    |
+------------+------+
| 30000      |   10 |
| 30000      |   10 |
+------------+------+
2 rows in set (0.00 sec)
tidb> select * from tt;
+------------+------+
| id         | c    |
+------------+------+
| 30000      |   10 |
+------------+------+
1 row in set (0.00 sec)

What is changed and how it works?

At the moment, if we have to deal with _tidb_rowid, it will be more complicated. So it is best not to support inserting, updating, and replacing _tidb_rowid statements now. But we have some tools that need to write _tidb_rowid, these tools will guarantee that they will not appear as above.
Currently, we want users not to open AllowWriteRowID.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

@zimulala zimulala added type/bug-fix This PR fixes a bug. sig/execution SIG execution status/WIP labels Oct 31, 2018
@zimulala
Copy link
Contributor Author

zimulala commented Nov 1, 2018

/run-all-tests

@morgo
Copy link
Contributor

morgo commented Nov 1, 2018

I believe this might break https://github.com/pingcap/mydumper 's restore.

PTAL @kennytm

@kennytm
Copy link
Contributor

kennytm commented Nov 1, 2018

Could we have an internal flag which allows INSERT to accept a _tidb_rowid column? Lightning requires _tidb_rowid to ensure idempotence when importing the same part of the table twice after resuming from a lagged checkpoint. Maybe Loader needs this too.

executor/write.go Outdated Show resolved Hide resolved
@zimulala
Copy link
Contributor Author

zimulala commented Nov 1, 2018

/run-all-tests tidb-test=release-2.0 tidb-private-test=release-2.0 tikv=release-2.0

@WangXiangUSTC
Copy link
Contributor

in tidb-binlog, we use _tidb_rowid to guarantee the idempotence when table's PKIsHandle is false. same with lightning and loader.

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala changed the title executor: insert, update and replace statements for rowid are not support executor: add a variable to control whether we can write _tidb_rowid Nov 5, 2018
@zimulala zimulala added status/LGT1 Indicates that a PR has LGTM 1. and removed status/DNM labels Nov 5, 2018
@zimulala
Copy link
Contributor Author

zimulala commented Nov 5, 2018

PTAL @jackysp

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 5, 2018
@zz-jason zz-jason merged commit a53e418 into pingcap:release-2.0 Nov 5, 2018
@zimulala zimulala deleted the rowid branch November 5, 2018 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/LGT2 Indicates that a PR has LGTM 2. type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants