-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: only use runningJobs to check job dependency #54003
Conversation
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Hi @lance6716. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
Signed-off-by: lance6716 <lance6716@gmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54003 +/- ##
=================================================
- Coverage 74.5294% 56.1069% -18.4226%
=================================================
Files 1516 1638 +122
Lines 360821 610295 +249474
=================================================
+ Hits 268918 342418 +73500
- Misses 72393 244462 +172069
- Partials 19510 23415 +3905
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: lance6716 <lance6716@gmail.com>
/retest |
@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
placement policy
and resource group
are out of our check currently, we need to make sure 2 jobs of same name doesn't run concurrently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to merge InvolvingSchemaInfo
which cames from foreign key for multiple schema change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create table with foreign key also need it, but i have add it in #54041 for some tests depends on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For placement policy and resource group, do you think we can add another field for InvolvingSchemaInfo
to record the dependency or other implementation? also cc @tangenta
I'll consider FK in next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now placement policy and resource group will set its name to job.Schema, if they have same namespace as database, seems ok to set InvolvingSchemaInfo = xx.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
placement policy and resource group related ddl all have a none, none
InvolvingSchemaInfo😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding another field maybe better. It is weird if a policy job blocks a create-database job..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it's a bit complex and I only want to add a TODO in this PR. Because there're exclusive jobs and shared jobs. Like CreatePlacementPolicy that directly modifies PlacementPolicy, and AlterTablePlacement that referring PlacementPolicy. Two AlterTablePlacement jobs should not have dependency.
And I think CREATE TABLE LIKE and FK are simliar. I want to leave this PR to this situation:
- When two jobs only referring to an object, in other words, does not modify it, the jobs have no dependency
- A referring job and a modifying job to the same object have no dependency. (I'll add TODO and improve it in next PR)
- Two modifying jobs have dependency.
I'll commit soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When two jobs only referring to an object, in other words, does not modify it, the jobs have no dependency
we should take them as depends on each other now as when calculate dependency we don't consider skipped jobs now, suppose this
- job 1: create table a ...foreign key refer test.t
- job 2: alter table test.t
- job 3: create table b ...foreign key refer test.t
job 1 can run, but not job 2, when we check job 3, we need consider job 2, not run it directly.
A referring job and a modifying job to the same object have no dependency.
do you mean job 1 create table a foreign key test.t; job 2 alter table test.t
have no dependency? i think it does if job 2 modify the referred column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
job 1: create table a ...foreign key refer test.t
job 2: alter table test.t
job 3: create table b ...foreign key refer test.t
job 1 can run, but not job 2, when we check job 3, we need consider job 2, not run it directly.
I think this is the case of fair lock. I'll keep this property in next PR
do you mean job 1 create table a foreign key test.t; job 2 alter table test.t have no dependency? i think it does if job 2 modify the referred column
It should have dependency, but I also want to leave it for next PR. In next PR I'll add exclusive
and shared
fields to runningJobs
and InvolvingSchemaInfo
to implement it.
pkg/ddl/ddl_api.go
Outdated
@@ -7949,7 +7969,17 @@ func (d *ddl) CreateForeignKey(ctx sessionctx.Context, ti ast.Ident, fkName mode | |||
BinlogInfo: &model.HistoryInfo{}, | |||
Args: []any{fkInfo, fkCheck}, | |||
CDCWriteSource: ctx.GetSessionVars().CDCWriteSource, | |||
SQLMode: ctx.GetSessionVars().SQLMode, | |||
InvolvingSchemaInfo: []model.InvolvingSchemaInfo{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop foreign key also need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that in the execution code dropForeignKey
, it does not check the existence of RefSchema / RefTable, maybe in this way it's more rubust.
@crazycs520 Do you think we should check dependency for the reference table of drop foreign key?
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
/unhold |
pkg/ddl/ddl_api.go
Outdated
@@ -2829,31 +2829,16 @@ func (d *ddl) createTableWithInfoJob( | |||
args = append(args, ctx.GetSessionVars().ForeignKeyChecks) | |||
} | |||
|
|||
involvingSchemaInfo := make([]model.InvolvingSchemaInfo, 0, len(tbInfo.ForeignKeys)+1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it's removed? and below FK for multi schema change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to allow CREATE TABLE t1 FOREIGN KEY t0.c0 and CREATE TABLE t2 FOREIGN KEY t0.c0 running concurrently in this PR. See below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, CI is failed because of this...
TestTruncateOrDropTableWithForeignKeyReferred2
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
/retest |
@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
/retest |
@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
/retest |
@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: D3Hunter, 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 |
What problem does this PR solve?
Issue Number: ref #52795, #53246
Problem Summary:
What changed and how does it work?
assuming there's one DDL owner at any time, we don't need to query persistent data of running DDL jobs. Instead, we can check the memory cache of running DDL jobs.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.