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: set jobs dependency by schema and table name #49699

Merged
merged 13 commits into from
Dec 26, 2023

Conversation

tangenta
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #49498

Problem Summary:

We should also consider schema & table name before picking a DDL job to execute.

What changed and how does it work?

  • Extract ddl.runningJobs to a separate file.
  • Add AffectedSchemaNames and AffectedTableNames to model.Job.
  • Refine job depenency check.

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-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 22, 2023
Copy link

tiprow bot commented Dec 22, 2023

Hi @tangenta. 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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. and removed do-not-merge/needs-triage-completed labels Dec 22, 2023
@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Dec 22, 2023
Copy link

codecov bot commented Dec 22, 2023

Codecov Report

Merging #49699 (688b703) into master (e418f2d) will increase coverage by 0.4784%.
Report is 39 commits behind head on master.
The diff coverage is 73.5135%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49699        +/-   ##
================================================
+ Coverage   70.9732%   71.4517%   +0.4784%     
================================================
  Files          1368       1429        +61     
  Lines        398095     421637     +23542     
================================================
+ Hits         282541     301267     +18726     
- Misses        95813     101425      +5612     
+ Partials      19741      18945       -796     
Flag Coverage Δ
integration 43.8332% <73.5135%> (?)
unit 70.9681% <ø> (-0.0051%) ⬇️

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 47.1538% <ø> (-5.7502%) ⬇️

@@ -6898,6 +6924,9 @@ func (d *ddl) renameTables(ctx sessionctx.Context, oldIdents, newIdents []ast.Id
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{oldSchemaIDs, newSchemaIDs, tableNames, tableIDs, oldSchemaNames, oldTableNames},
CtxVars: []interface{}{append(oldSchemaIDs, newSchemaIDs...), tableIDs},

AffectedSchemaNames: affectedSchemaNames,
AffectedTableNames: affectedTableNames,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put these fields to MultiSchemaInfo?
There seems to be some overlap between TableName and AffectedTableNames.
But in that case, the rename table operation is a little tricky to explain. Or we can specially handle this operation by getting the RawArgs information.

Copy link
Contributor Author

@tangenta tangenta Dec 25, 2023

Choose a reason for hiding this comment

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

No, MultiSchemaInfo is only used for multi-schema changes, and this PR is not related to multi-schema changes.

rename table may change RawArgs during execution, with increasing complexity.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or consider putting some related fields into a field of this Job.

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.

Could we use AffectedSchemaNames to update job2SchemaNames
#43818

}
create1TS, dropTS, create0TS := finishTSs[0], finishTSs[1], finishTSs[2]
require.Less(t, create0TS, dropTS, "first create should finish before drop")
require.Less(t, dropTS, create1TS, "second create should finish after drop")
Copy link
Contributor

Choose a reason for hiding this comment

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

Test failed:

 ddl_api_test.go:214: 
        	Error Trace:	pkg/ddl/ddl_api_test.go:214
        	Error:      	"446560642158297088" is not less than "446560641896677376"
        	Test:       	TestCreateDropCreateTable

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 failpoint mockOwnerCheckAllVersionSlow does not work in time. I have changed the sleep time from 1 second to 2 seconds.


type runningJobs struct {
sync.RWMutex
ids map[int64][]model.InvolvingSchemaInfo
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add another map(as revert index) using schema+tablen as the key and the "jobid1, jobid2" string as a value to make check conflict more efficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 26, 2023
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 26, 2023
@@ -6898,6 +6934,8 @@ func (d *ddl) renameTables(ctx sessionctx.Context, oldIdents, newIdents []ast.Id
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{oldSchemaIDs, newSchemaIDs, tableNames, tableIDs, oldSchemaNames, oldTableNames},
CtxVars: []interface{}{append(oldSchemaIDs, newSchemaIDs...), tableIDs},

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

@@ -5044,6 +5066,10 @@ func (d *ddl) ExchangeTablePartition(ctx sessionctx.Context, ident ast.Ident, sp
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{defID, ptSchema.ID, ptMeta.ID, partName, spec.WithValidation},
CtxVars: []interface{}{[]int64{ntSchema.ID, ptSchema.ID}, []int64{ntMeta.ID, ptMeta.ID}},
InvolvingSchemaInfo: []model.InvolvingSchemaInfo{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I saw you have added one blank line since 6937, please make it all consistent.

Copy link
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 26, 2023
Copy link

ti-chi-bot bot commented Dec 26, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-26 04:03:39.395946927 +0000 UTC m=+1538510.433173851: ☑️ agreed by zimulala.
  • 2023-12-26 06:05:36.783923033 +0000 UTC m=+1545827.821149960: ☑️ agreed by Benjamin2037.

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.

parser part lgtm

Copy link

ti-chi-bot bot commented Dec 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, D3Hunter, zimulala

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 Dec 26, 2023
@ti-chi-bot ti-chi-bot bot merged commit 2dfbaa8 into pingcap:master Dec 26, 2023
16 of 17 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #49782.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 26, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #49783.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 26, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #49784.

@okJiang
Copy link
Member

okJiang commented Feb 19, 2024

/cherry-pick release-6.5-20231229-v6.5.6

@ti-chi-bot
Copy link
Member

@okJiang: new pull request created to branch release-6.5-20231229-v6.5.6: #51133.

In response to this:

/cherry-pick release-6.5-20231229-v6.5.6

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 19, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. 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.

TiCDC receive DDLs out of order by the DDL Job StartTs
6 participants