-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: add job version 2 and use typed args for truncate table #55854
Conversation
Hi @D3Hunter. 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. |
@@ -289,14 +329,14 @@ type Job struct { | |||
Query string `json:"query"` | |||
BinlogInfo *HistoryInfo `json:"binlog"` | |||
|
|||
// Version indicates the DDL job version. For old jobs, it will be 0. |
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.
since version v1.0.0, the job version is already 1, so there shouldn't be jobs of version 0 now. see https://github.com/pingcap/tidb/pull/3993/files#diff-a185df836b8926c4afe351d4def1b56d1e282c65aabe6677c2fa2c54590cc4b2R44-R45
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #55854 +/- ##
=================================================
- Coverage 72.8514% 57.1298% -15.7217%
=================================================
Files 1601 1756 +155
Lines 445302 633207 +187905
=================================================
+ Hits 324409 361750 +37341
- Misses 100894 246610 +145716
- Partials 19999 24847 +4848
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/retest |
@D3Hunter: 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 |
@D3Hunter: 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. |
Maybe we could abstract some function, like this:
And we can call this function in DDL jobSubmit and ddl jobScheduler and ...., put together functions that modify related parameters for different DDL type. |
/retest |
@D3Hunter: 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. |
pkg/ddl/executor.go
Outdated
@@ -6426,7 +6429,12 @@ func (e *executor) DoDDLJobWrapper(ctx sessionctx.Context, jobW *JobWrapper) (re | |||
func HandleLockTablesOnSuccessSubmit(ctx sessionctx.Context, jobW *JobWrapper) { | |||
if jobW.Type == model.ActionTruncateTable { | |||
if ok, lockTp := ctx.CheckTableLocked(jobW.TableID); ok { | |||
newTableID := jobW.Args[0].(int64) | |||
var newTableID int64 | |||
if jobW.Version == model.JobVersion1 { |
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.
like GetTruncateTableArgsBeforeRun
, this part can also be encapsulated?
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.
pkg/ddl/executor.go
Outdated
@@ -6437,7 +6445,12 @@ func HandleLockTablesOnSuccessSubmit(ctx sessionctx.Context, jobW *JobWrapper) { | |||
func HandleLockTablesOnFinish(ctx sessionctx.Context, jobW *JobWrapper, ddlErr error) { | |||
if jobW.Type == model.ActionTruncateTable { | |||
if ddlErr != nil { | |||
newTableID := jobW.Args[0].(int64) | |||
var newTableID int64 | |||
if jobW.Version == model.JobVersion1 { |
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.
ditto
pkg/ddl/job_scheduler.go
Outdated
@@ -723,7 +723,13 @@ func job2UniqueIDs(job *model.Job, schema bool) string { | |||
if schema { | |||
return strconv.FormatInt(job.SchemaID, 10) | |||
} | |||
return strconv.FormatInt(job.TableID, 10) + "," + strconv.FormatInt(job.Args[0].(int64), 10) | |||
var newTableID int64 | |||
if job.Version == model.JobVersion1 { |
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.
ditto
@lance6716 also add another API for changed args, see https://github.com/pingcap/tidb/pull/55919/files#diff-0a328bfc50df4984d8b701f6cfb588c8bc675992e32e00ae05f2d900147ea8dfR44-R46 |
/retest |
@D3Hunter: 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. |
partIDs := make([]int64, partCount) | ||
for i := range partIDs { | ||
partIDs[i] = alloc.next() | ||
if jobW.Version == model.JobVersion1 { |
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 these getter logic, I prefer we always use a function to convert all version representations to TruncateTableArgs
, then caller use TruncateTableArgs
.
like
if !jobW.IDAllocated {
arg := getTruncateTableArgs(job)
arg.NewTableID = alloc.next()
...
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 new jobs, i plan put JobArgs into JobWrapper, and fill to job on insert, so we can use it directly here.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: joccau, lance6716, 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 |
/retest |
@D3Hunter: 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 |
@D3Hunter: 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 |
@D3Hunter: 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 |
@D3Hunter: 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. |
What problem does this PR solve?
Issue Number: ref #53930
Problem Summary:
What changed and how does it work?
Check List
Tests
manually run TruncateTable tests using job version 2, success
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.