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/importinto: fix insert err after import for AUTO_ID_CACHE=1 and SHARD_ROW_ID_BITS #52712

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Apr 18, 2024

What problem does this PR solve?

Issue Number: close #52654

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
mysql> CREATE TABLE t (
    ->   id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    ->   PRIMARY KEY (id) /*T![clustered_index] NONCLUSTERED */
    -> ) /*T![auto_id_cache] AUTO_ID_CACHE=1 */ /*T! SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=3 */;
Query OK, 0 rows affected (0.09 sec)

mysql>
mysql> import into t from select 1778961125641936898;
Query OK, 1 row affected (0.30 sec)
Records: 1, ID: 0e8a4adb-47df-4790-a237-5a489e25d9c6

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

mysql> select *, _tidb_rowid from t;
+---------------------+---------------------+
| id                  | _tidb_rowid         |
+---------------------+---------------------+
| 1778961125641936898 | 1152921504606846977 |
| 1778961125641936899 | 2882303761517117442 |
+---------------------+---------------------+
2 rows in set (0.01 sec)
mysql> select *, _tidb_rowid & x'07FFFFFFFFFFFFFF' from t;
+---------------------+-----------------------------------+
| id                  | _tidb_rowid & x'07FFFFFFFFFFFFFF' |
+---------------------+-----------------------------------+
| 1778961125641936899 |                                 2 |
| 1778961125641936898 |                                 1 |
+---------------------+-----------------------------------+
2 rows in set (0.01 sec)
  • No need to test
    • I checked and no code files have been changed.

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 ti-chi-bot bot added do-not-merge/needs-triage-completed 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 Apr 18, 2024
Copy link

tiprow bot commented Apr 18, 2024

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@D3Hunter D3Hunter changed the title lightning: fix insert err after import for AUTO_ID_CACHE=1 and SHARD_ROW_ID_BITS lightning/importinto: fix insert err after import for AUTO_ID_CACHE=1 and SHARD_ROW_ID_BITS Apr 18, 2024
@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. labels Apr 18, 2024
Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Merging #52712 (10c5767) into master (f4e0d58) will increase coverage by 1.1544%.
Report is 3 commits behind head on master.
The diff coverage is 97.2222%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52712        +/-   ##
================================================
+ Coverage   72.3622%   73.5166%   +1.1544%     
================================================
  Files          1471       1493        +22     
  Lines        427144     435614      +8470     
================================================
+ Hits         309091     320249     +11158     
+ Misses        98814      95298      -3516     
- Partials      19239      20067       +828     
Flag Coverage Δ
integration 48.1835% <94.4444%> (?)
unit 71.2000% <89.4736%> (-0.0527%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 41.3923% <ø> (+0.2930%) ⬆️

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 18, 2024
@D3Hunter
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 18, 2024

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@D3Hunter
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 18, 2024

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

// for TiDB version >= 6.5.0, a table might have separate allocators for auto_increment column and _tidb_rowid,
// especially when a table has auto_increment non-clustered PK, it will use both allocators.
// And in this case, ALTER TABLE xxx AUTO_INCREMENT = xxx only works on the allocator of auto_increment column,
// not for allocator of _tidb_rowid.
// So we need to rebase IDs for those 2 allocators explicitly.
err = common.RebaseGlobalAutoID(ctx, adjustIDBase(newBase), tr, tr.dbInfo.ID, tr.tableInfo.Core)
err = common.RebaseTableAllocators(ctx, map[autoid.AllocatorType]int64{
autoid.RowIDAllocType: tr.alloc.Get(autoid.RowIDAllocType).Base(),
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also rebase to Base()+1? The Base() is the used value or next value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need add 1, it's last used value

@D3Hunter
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 18, 2024

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

Copy link

ti-chi-bot bot commented Apr 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, lance6716

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 18, 2024
Copy link

ti-chi-bot bot commented Apr 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-18 07:11:19.736047041 +0000 UTC m=+494898.847093490: ☑️ agreed by GMHDBJD.
  • 2024-04-18 07:37:31.546322972 +0000 UTC m=+496470.657369421: ☑️ agreed by lance6716.

@ti-chi-bot ti-chi-bot bot merged commit 72e5460 into pingcap:master Apr 18, 2024
24 checks passed
@D3Hunter D3Hunter deleted the lit-autoidcache branch April 18, 2024 08:11
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #52722.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #52723.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 18, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #52724.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #53704.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 31, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compatible issue when using lightning + SHARD_ROW_ID_BITS + AUTO_ID_CACHE=1
4 participants