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

lightning: support null value for auto-incr column on local backend #34552

Merged
merged 8 commits into from
May 12, 2022

Conversation

dsdashun
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #34208

Problem Summary:

What is changed and how it works?

When encoding the SQL into a TiDB KV for importing, if the value is NULL in a 'not-null' column, go on further processing on special column types rather than convert those NULL values into zero values directly

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented May 10, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • D3Hunter
  • gozssky

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added needs-cherry-pick-6.0 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 10, 2022
@sre-bot
Copy link
Contributor

sre-bot commented May 10, 2022

@dsdashun dsdashun marked this pull request as ready for review May 11, 2022 00:50
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 11, 2022
@dsdashun
Copy link
Contributor Author

/cc @gozssky @D3Hunter PTAL

@ti-chi-bot
Copy link
Member

@dsdashun: GitHub didn't allow me to request PR reviews from the following users: PTAL.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @gozssky @D3Hunter PTAL

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 kubernetes/test-infra repository.

br/pkg/lightning/backend/kv/sql2kv.go Outdated Show resolved Hide resolved
br/tests/lightning_issue_34208/run.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@sleepymole sleepymole left a comment

Choose a reason for hiding this comment

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

rest LGTM

br/tests/lightning_issue_34208/run.sh Outdated Show resolved Hide resolved
* Added some UT to test the `getActualDatum()`
* add some 'not_contains' check on zero id value
Co-authored-by: Yujie Xia <xiayjchn@gmail.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 11, 2022
@sleepymole
Copy link
Contributor

/run-integration-br-test

@dsdashun
Copy link
Contributor Author

/run-check_dev_2

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

rest lgtm

br/tests/lightning_issue_34208/config.toml Outdated Show resolved Hide resolved
br/pkg/lightning/backend/kv/sql2kv.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/kv/sql2kv.go Outdated Show resolved Hide resolved
@D3Hunter
Copy link
Contributor

D3Hunter commented May 11, 2022

current behavior looks odd to me, in data file it's null for a auto_incrment primary key column, then we generate an id automatically for it. what if it's just an corrupted data file, in that case we should not do it:

what's current behavior for case below:

table is create table t(id int primary key auto_increment, v varchar(10));, but in data file(csv), we have:

1,aaa
NULL,bbb
NULL,ccc
2,ddd

@sleepymole
Copy link
Contributor

@D3Hunter TiDB supports insert NULL as auto_incrment column.

mysql> create table t(id int primary key auto_increment, v varchar(10));
Query OK, 0 rows affected (0.12 sec)

mysql> insert into t values (1, 'aaa');
Query OK, 1 row affected (0.03 sec)

mysql> insert into t values (NULL, 'bbb');
Query OK, 1 row affected (0.02 sec)

mysql> insert into t values (NULL, 'ccc');
Query OK, 1 row affected (0.01 sec)

mysql> insert into t values (2, 'ddd');
ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY'
mysql> select * from t;
+----+------+
| id | v    |
+----+------+
|  1 | aaa  |
|  2 | bbb  |
|  3 | ccc  |
+----+------+
3 rows in set (0.01 sec)

For local backend, we need to enable duplicate-resolution to detect the primary key conflict.

@dsdashun
Copy link
Contributor Author

/run-integration-br-test

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 12, 2022
@sleepymole
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: f5efbc9

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 12, 2022
@ti-chi-bot ti-chi-bot merged commit b824e35 into pingcap:master May 12, 2022
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request May 12, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-6.0 in PR #34595

@sre-bot
Copy link
Contributor

sre-bot commented May 12, 2022

TiDB MergeCI notify

🔴 Bad News! New failing [1] after this pr merged.
These new failed integration tests seem to be caused by the current PR, please try to fix these new failed integration tests, thanks!

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test 🟥 failed 1, success 33, total 34 31 min New failing
idc-jenkins-ci-tidb/integration-common-test 🟢 all 11 tests passed 16 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 8 min 17 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 6 min 49 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 49 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 5 min 42 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 42 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 12 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 1 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

@dsdashun dsdashun deleted the fix34208 branch June 17, 2022 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightning import fails if auto_increment / auto_random column is NULL and backend is local/importer
6 participants