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: refactor job args for set-default-value/add column ddl. #56337

Merged
merged 15 commits into from
Sep 30, 2024

Conversation

joccau
Copy link
Member

@joccau joccau commented Sep 26, 2024

What problem does this PR solve?

Issue Number: Ref #53930
Ref #54436

Problem Summary:

What changed and how does it work?

Refactor the job args for follow ddl type:

  • ActionSetDefaultValue
  • ActionAddColumn

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 do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked labels Sep 26, 2024
@joccau joccau changed the title ddl: refactor job args for setd-default-value ddl. ddl: refactor job args for set-default-value ddl. Sep 26, 2024
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 96.25000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 76.2759%. Comparing base (c46e4bc) to head (7fe2576).
Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #56337        +/-   ##
================================================
+ Coverage   73.4163%   76.2759%   +2.8596%     
================================================
  Files          1623       1645        +22     
  Lines        447906     456984      +9078     
================================================
+ Hits         328836     348569     +19733     
+ Misses        98924      86847     -12077     
- Partials      20146      21568      +1422     
Flag Coverage Δ
integration 52.0158% <67.5000%> (?)
unit 72.6973% <96.2500%> (+0.1929%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 63.0723% <ø> (+17.5396%) ⬆️

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 26, 2024
@joccau joccau changed the title ddl: refactor job args for set-default-value ddl. ddl: refactor job args for set-default-value/add column ddl. Sep 26, 2024
@hawkingrei
Copy link
Member

/test fast_test_tiprow_ddl

Copy link

ti-chi-bot bot commented Sep 26, 2024

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

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

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

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_br_integration_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_lightning_integration_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow_ddl

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 previously approved these changes Sep 27, 2024
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 27, 2024
@joechenrh
Copy link
Contributor

joechenrh commented Sep 27, 2024

Shall we change arguments toDropColumnArgs in rollingbackAddColumn using FillArgs?

tidb/pkg/ddl/rollingback.go

Lines 187 to 210 in f2ed822

func rollingbackAddColumn(jobCtx *jobContext, t *meta.Meta, job *model.Job) (ver int64, err error) {
tblInfo, columnInfo, col, _, _, err := checkAddColumn(t, job)
if err != nil {
return ver, errors.Trace(err)
}
if columnInfo == nil {
job.State = model.JobStateCancelled
return ver, dbterror.ErrCancelledDDLJob
}
originalState := columnInfo.State
columnInfo.State = model.StateDeleteOnly
job.SchemaState = model.StateDeleteOnly
job.Args = []any{col.Name}
ver, err = updateVersionAndTableInfo(jobCtx, t, job, tblInfo, originalState != columnInfo.State)
if err != nil {
return ver, errors.Trace(err)
}
job.State = model.JobStateRollingback
return ver, dbterror.ErrCancelledDDLJob
}

It's used here, which assumes that the arguments are filled by DropColumnArgs?
func onAddColumn(jobCtx *jobContext, t *meta.Meta, job *model.Job) (ver int64, err error) {
// Handle the rolling back job.
if job.IsRollingback() {
ver, err = onDropColumn(jobCtx, t, job)
if err != nil {
return ver, errors.Trace(err)
}
return ver, nil

type AddColumnArgs struct {
Col *ColumnInfo `json:"column_info,omitempty"`
Pos *ast.ColumnPosition `json:"position,omitempty"`
Offset int `json:"offset,omitempty"`
Copy link
Contributor

@joechenrh joechenrh Sep 27, 2024

Choose a reason for hiding this comment

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

Seems like Offset is never used. Just remove it and put zero in fillJob?

@D3Hunter
Copy link
Contributor

Shall we change arguments toDropColumnArgs in rollingbackAddColumn using FillArgs?

tidb/pkg/ddl/rollingback.go

Lines 187 to 210 in f2ed822

func rollingbackAddColumn(jobCtx *jobContext, t *meta.Meta, job *model.Job) (ver int64, err error) {
tblInfo, columnInfo, col, _, _, err := checkAddColumn(t, job)
if err != nil {
return ver, errors.Trace(err)
}
if columnInfo == nil {
job.State = model.JobStateCancelled
return ver, dbterror.ErrCancelledDDLJob
}
originalState := columnInfo.State
columnInfo.State = model.StateDeleteOnly
job.SchemaState = model.StateDeleteOnly
job.Args = []any{col.Name}
ver, err = updateVersionAndTableInfo(jobCtx, t, job, tblInfo, originalState != columnInfo.State)
if err != nil {
return ver, errors.Trace(err)
}
job.State = model.JobStateRollingback
return ver, dbterror.ErrCancelledDDLJob
}

It's used here, which assumes that the arguments are filled by DropColumnArgs?

func onAddColumn(jobCtx *jobContext, t *meta.Meta, job *model.Job) (ver int64, err error) {
// Handle the rolling back job.
if job.IsRollingback() {
ver, err = onDropColumn(jobCtx, t, job)
if err != nil {
return ver, errors.Trace(err)
}
return ver, nil

CI passes, seems it's not covered, too bad

the case is similar to how AddPartition is rollbacked

@joccau
Copy link
Member Author

joccau commented Sep 27, 2024

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2024
@D3Hunter D3Hunter dismissed their stale review September 27, 2024 03:56

code need change

@ti-chi-bot ti-chi-bot bot removed the approved label Sep 27, 2024
Copy link

ti-chi-bot bot commented Sep 30, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-27 03:24:36.969227899 +0000 UTC m=+1795546.709651837: ☑️ agreed by D3Hunter.
  • 2024-09-30 06:23:41.771353138 +0000 UTC m=+249577.191566145: ☑️ agreed by lance6716.

@D3Hunter
Copy link
Contributor

/test fast_test_tiprow_ddlargsv1

Copy link

ti-chi-bot bot commented Sep 30, 2024

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

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

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

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_br_integration_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_lightning_integration_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow_ddlargsv1

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

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Sep 30, 2024

@D3Hunter: 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.

@joccau
Copy link
Member Author

joccau commented Sep 30, 2024

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Sep 30, 2024

@joccau: 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.

@joccau
Copy link
Member Author

joccau commented Sep 30, 2024

/test pull-br-integration-test

Copy link

tiprow bot commented Sep 30, 2024

@joccau: 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-br-integration-test

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.

@joccau
Copy link
Member Author

joccau commented Sep 30, 2024

/test fast_test_tiprow

Copy link

ti-chi-bot bot commented Sep 30, 2024

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

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test
  • /test pull-unit-test-ddlv1

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

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_br_integration_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_lightning_integration_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow

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

/test fast_test_tiprow_ddlargsv1
/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Sep 30, 2024

@D3Hunter: 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 fast_test_tiprow_ddlargsv1
/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

/test fast_test_tiprow_ddlargsv1

Copy link

ti-chi-bot bot commented Sep 30, 2024

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

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test
  • /test pull-unit-test-ddlv1

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

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_br_integration_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_lightning_integration_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow_ddlargsv1

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

/hold

to wait V1 pass

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

/retest

@D3Hunter
Copy link
Contributor

/test fast_test_tiprow_ddlargsv1

Copy link

ti-chi-bot bot commented Sep 30, 2024

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

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test
  • /test pull-unit-test-ddlv1

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

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_br_integration_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_lightning_integration_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow_ddlargsv1

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.

@joccau
Copy link
Member Author

joccau commented Sep 30, 2024

/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 Sep 30, 2024
@D3Hunter
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 30, 2024
@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 Sep 30, 2024
@D3Hunter
Copy link
Contributor

/test pull-unit-test-ddlv1

Copy link

tiprow bot commented Sep 30, 2024

@D3Hunter: 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.

@ti-chi-bot ti-chi-bot bot merged commit 72f067b into pingcap:master Sep 30, 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 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.

6 participants