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

*: Require GLOBAL IndexOption for creating Global Index #55264

Merged

Conversation

mjonss
Copy link
Contributor

@mjonss mjonss commented Aug 7, 2024

What problem does this PR solve?

Issue Number: close #52994

Building upon #55259, which is the Parser change needed for this PR.

Problem Summary:
To not surprise our users and create MySQL incompatibilities, we should require explicit mentioning of 'GLOBAL' when creating a Global Unique Index.

This also makes it easier to allow non-unique indexes as well as unique indexes already containing all partitioning columns to be GLOBAL.

Currently ALTER TABLE t PARTITION BY ... would implicitly create a Global Index of UNIQUE Indexes if they don't include all partitioning columns.
With this PR we are adding an optional UPDATE INDEXES clause after the partitioning definitions:
UPDATE INDEXES ( index_name {GLOBAL|LOCAL} [, index_name {GLOBAL|LOCAL}[,...]] ) to make every index change explicit.

What changed and how does it work?

DDL:

  • Checking and propagating the options from the parser, so that we require GLOBAL to be explicitly mentioned when creating a global index.

Executor:

  • Including /*T![global_index] GLOBAL */ as IndexOption in SHOW CREATE TABLE

Table:

  • Just updated test to use GLOBAL IndexOption.

Added a new error for needing Global Index, but is not explicitly given.
Most changes are just updated tests and results, to comply with the new requirement of explicitly mention GLOBAL.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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.

Require GLOBAL IndexOption for creating a Global Index (experimental).

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-tests-checked sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 7, 2024
Copy link

tiprow bot commented Aug 7, 2024

Hi @mjonss. 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-sigs/prow repository.

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 79.84496% with 26 lines in your changes missing coverage. Please review.

Project coverage is 75.6112%. Comparing base (876268f) to head (24d3ec5).
Report is 18 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55264        +/-   ##
================================================
+ Coverage   74.7860%   75.6112%   +0.8251%     
================================================
  Files          1570       1580        +10     
  Lines        364854     449034     +84180     
================================================
+ Hits         272860     339520     +66660     
- Misses        72285      88722     +16437     
- Partials      19709      20792      +1083     
Flag Coverage Δ
integration 50.1754% <75.1938%> (?)
unit 71.9732% <72.8682%> (-1.7505%) ⬇️

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

Components Coverage Δ
dumpling 52.9567% <ø> (-2.2327%) ⬇️
parser ∅ <ø> (∅)
br 63.1826% <ø> (+15.5121%) ⬆️

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 9, 2024
@mjonss mjonss requested a review from tangenta August 9, 2024 12:47
@mjonss
Copy link
Contributor Author

mjonss commented Aug 9, 2024

/retest

Copy link

tiprow bot commented Aug 9, 2024

@mjonss: 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-sigs/prow repository.

@mjonss mjonss changed the title *: Require GLOBAL IndexOption for creating Global Index *: Require GLOBAL IndexOption for creating Global Index | tidb-test=pr/2377 Aug 9, 2024
@mjonss
Copy link
Contributor Author

mjonss commented Aug 9, 2024

/retest

Copy link

tiprow bot commented Aug 9, 2024

@mjonss: 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-sigs/prow repository.

@mjonss mjonss changed the title *: Require GLOBAL IndexOption for creating Global Index | tidb-test=pr/2377 *: Require GLOBAL IndexOption for creating Global Index Aug 9, 2024
idxOffset := -1
for i := range tbInfo.Indices {
if strings.EqualFold(tbInfo.Indices[i].Name.L, idxUpdate.Name) {
idxOffset = i
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 check is commonHandle here?

Copy link
Contributor Author

@mjonss mjonss Aug 12, 2024

Choose a reason for hiding this comment

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

Not sure, it is checked in the next loop over tbInfo.Indices, and will fail if CommonIndex and global index is needed for the same index.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 12, 2024
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

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

LGTM for the optimizer part

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

ti-chi-bot bot commented Aug 12, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-12 07:08:13.960062615 +0000 UTC m=+165378.663532243: ☑️ agreed by Defined2014.
  • 2024-08-12 08:19:12.455645015 +0000 UTC m=+169637.159114675: ☑️ agreed by qw4990.

@mjonss
Copy link
Contributor Author

mjonss commented Aug 12, 2024

/retest

Copy link

tiprow bot commented Aug 12, 2024

@mjonss: 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-sigs/prow repository.

Copy link

ti-chi-bot bot commented Aug 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, qw4990, tangenta

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 the approved label Aug 12, 2024
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit 2fb61a5 into pingcap:master Aug 12, 2024
24 checks passed
@mjonss mjonss deleted the global-index-require-global-index-option branch August 12, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GLOBAL as IndexOption and require it explicitly for GLOBAL INDEX
5 participants