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

ddl: add syntax for setting the cache step of auto id explicitly. (#15409) #16287

Merged
merged 6 commits into from
Apr 28, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Apr 10, 2020

cherry-pick #15409 to release-3.0

conflict files

1:autoid.go 
Because of the lack of NewAllocatorFromTableInfo interface, so we pass the auto_id_cache as an additional parameter based on the NewAllocator interface
2:binlogInfo.go
AddSpecialComment has been changed a litter bit in autoRandom's PR, so I have backported it.
3:Another conflicts are all position conflicts

What problem does this PR solve?

That autoid allocator's cache step is quite big now, it will consume a lot of autoid when tidb restarts or crashes. For those scenes which treasure autoid heavily, it's not acceptable.

Parser link: #765

Problem Summary:

What is changed and how it works?

Add auto_increment_cache in create table / alter table statement and it will determine the allocator's cache step.

But there is an exception when a statement like an insert batch(insert into values()()...) which requires allocating consecutive N autoid in one statement, we will make sure that the custom cache step is adequate for it with if step < N, then step = min(2N, maxstep)

Attention please:
tidb handle share the same allocator with auto_increment, so here:
auto_increment_cache will take effect on handle if PKIshandle is false, or even there is no auto_increment column at all.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • PR to update pingcap/tidb-ansible:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note:

ddl: add syntax for setting the cache step of auto id explicitly.

@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 10, 2020

/run-all-tests

executor/show_test.go Outdated Show resolved Hide resolved
@AilinKid AilinKid force-pushed the release-3.0-1c73deca59e4 branch 2 times, most recently from c1f2860 to e9a6295 Compare April 28, 2020 09:13
AilinKid and others added 5 commits April 28, 2020 18:09
Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

LGTM

@AilinKid
Copy link
Contributor

/run-all-tests

@AilinKid AilinKid added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 28, 2020
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133 bb7133 merged commit 62e8314 into pingcap:release-3.0 Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra status/LGT1 Indicates that a PR has LGTM 1. type/3.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants