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: args v2 for add/drop/rename index, include PK/vector-index #56130

Merged
merged 39 commits into from
Oct 12, 2024

Conversation

joechenrh
Copy link
Contributor

@joechenrh joechenrh commented Sep 18, 2024

What problem does this PR solve?

Issue Number: ref #53930

Problem Summary:

What changed and how does it work?

As title.

Most part of this PR is to make the arguments compatible with V1.

Below lists the layout of arguments used in V1, which may help to read this PR:

Add index done:
    [ []int64, []bool, []int64, []bool ] <-- [ indexIDs, ifExists, partitionIDs, isGlobals ]
Rolling back add index:
    [ []CIStr, []bool, []int64 ] <-- [ indexNames, ifExists, partitionIDs ]
Rollback add index done:
    [ []int64, []bool, []int64 ] <-- [ indexIDs, ifExists, partitionIDs ]
Drop index
    [ []CIStr, bool ] <-- [ indexName, ifExist ]
Drop index done
    [ CIStr, bool, int64, []int64, bool ] <-- [ indexName, ifExist, indexID, partitionIDs, isVector ]
RunningArgs                  Add Index ---------------------------------               Drop Index
  (FillArgs)                     |			                |                   |
                                 |		    	                |                   |
                                 |		                        |                   |
                                 v 			                v                   v
FinishedArgs             Add Index Done   Rollback done <--- Rolling back add index   Drop Index Done
(FillFinishedArgs)       -------------------------------     -----------------------------------------
                              Almost the same                       Share the first two elements,
                                                                     used in checkDropIndex

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.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 18, 2024
Copy link

tiprow bot commented Sep 18, 2024

Hi @joechenrh. 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 Sep 18, 2024

Codecov Report

Attention: Patch coverage is 85.35262% with 81 lines in your changes missing coverage. Please review.

Project coverage is 57.5172%. Comparing base (df821b9) to head (d870599).
Report is 53 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #56130         +/-   ##
=================================================
- Coverage   73.2357%   57.5172%   -15.7186%     
=================================================
  Files          1626       1778        +152     
  Lines        448692     645899     +197207     
=================================================
+ Hits         328603     371503      +42900     
- Misses        99977     249121     +149144     
- Partials      20112      25275       +5163     
Flag Coverage Δ
integration 39.2984% <75.0452%> (?)
unit 72.6915% <88.6315%> (+0.2514%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 61.6304% <60.0000%> (+16.1590%) ⬆️

@joechenrh joechenrh force-pushed the addargs-indexes branch 2 times, most recently from 803f379 to dc1642c Compare September 20, 2024 05:50
@joechenrh joechenrh changed the title ddl: args v2 for add/drop index/primary key ddl: args v2 for add/drop/rename index/primary key Sep 23, 2024
@D3Hunter D3Hunter mentioned this pull request Sep 23, 2024
54 tasks
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 28, 2024
@D3Hunter
Copy link
Contributor

please fix conflicts

@joechenrh
Copy link
Contributor Author

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Sep 30, 2024

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

In response to this:

/test pull-unit-test-ddlv1

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.

@joechenrh joechenrh changed the title ddl: args v2 for add/drop/rename index/primary key ddl: args v2 for add/drop/rename index/vector index/primary key Oct 8, 2024
@joechenrh
Copy link
Contributor Author

/retest

@joechenrh
Copy link
Contributor Author

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Oct 11, 2024

@joechenrh: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test fast_test_tiprow_ddlargsv1
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • fast_test_tiprow
  • tidb_parser_test

In response to this:

/test pull-unit-test-ddlv1

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
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

IndexArgs []*IndexArg `json:"index_args,omitempty"`

// Belows are used for finished args.
// For dropping index, len(IndexIDs) is 1.
// While during rolling back add indexes, IndexIDs stores the partition IDs of the corresponding table.
Copy link
Contributor

Choose a reason for hiding this comment

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

too bad 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

too bad 🙃

You mean the comment, or this field? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I need to rename these two fields. They are confusing indeed.

Copy link
Contributor

Choose a reason for hiding this comment

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

IndexIDs stores the partition IDs of the corresponding table.

I mean this.

Maybe I need to rename these two fields. They are confusing indeed.

if the change is large, you can write a TODO and do it in other pr, this one too large

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 11, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2024
ifExists := make([]bool, 1)
isGlobal := make([]bool, 0, 1)
var partitionIDs []int64
if err := job.DecodeArgs(&allIndexIDs[0], &ifExists[0], &partitionIDs); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first decode is useless, since the first two elements are slice after #47135.
So in the new logic, we only decode them using slice.

isVector := false

// See getFinishedArgsV1 for why we may need to decode twice.
if err := job.DecodeArgs(&indexNames, &ifExists, &indexIDs, &isVector); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't partitionIDs field here?

Copy link
Contributor Author

@joechenrh joechenrh Oct 11, 2024

Choose a reason for hiding this comment

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

The partitionIDs are stored in IndexIDs fields for rolling back add index/primary key currently.
And I plan to change this confusing code in another pr. 😢
Updated

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

/hold

feel free to unhold after check my comments

pkg/ddl/index.go Outdated Show resolved Hide resolved
pkg/meta/model/job_args.go Outdated Show resolved Hide resolved
pkg/meta/model/job_args.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 12, 2024
Copy link

ti-chi-bot bot commented Oct 12, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-11 07:54:31.994744856 +0000 UTC m=+1205427.414957868: ☑️ agreed by D3Hunter.
  • 2024-10-12 02:38:58.54791669 +0000 UTC m=+65935.696826521: ☑️ agreed by lance6716.

Copy link

ti-chi-bot bot commented Oct 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716, Leavrth

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 Oct 12, 2024
@joechenrh
Copy link
Contributor Author

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Oct 12, 2024

@joechenrh: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test fast_test_tiprow_ddlargsv1
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • fast_test_tiprow
  • tidb_parser_test

In response to this:

/test pull-unit-test-ddlv1

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.

@D3Hunter
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 12, 2024
@D3Hunter
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot bot merged commit 89a5571 into pingcap:master Oct 12, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. 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.

6 participants