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) #16288

Merged
merged 5 commits into from
Apr 26, 2020

Conversation

sre-bot
Copy link
Contributor

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

cherry-pick #15409 to release-3.1

In master: the merge order is 
1: auto_id_cache 
2: auto_random_option

Cause auto_random_option has merged first in 3.1, 
so here is a little bit different in code, but no big conflicts in cherry-picking

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

model.ActionModifySchemaCharsetAndCollate:
=======
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the conflicts.
@AilinKid

@AilinKid
Copy link
Contributor

blocked by another parser PR

@AilinKid AilinKid requested review from zimulala, bb7133 and djshow832 and removed request for bb7133 and djshow832 April 26, 2020 07:34
@AilinKid
Copy link
Contributor

/run-unit-test

Copy link
Contributor

@Deardrops Deardrops left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zimulala zimulala 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 added the status/can-merge Indicates a PR has been approved by a committer. label Apr 26, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 26, 2020

/run-all-tests

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

@sre-bot sre-bot merged commit 78f3c25 into pingcap:release-3.1 Apr 26, 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/can-merge Indicates a PR has been approved by a committer. type/3.1-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants