-
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: sync schema version using watch, notify sessions on owner node by job id #53217
Conversation
Skipping CI for Draft Pull Request. |
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. |
/test all |
@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. |
/test all |
@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. |
/test all |
@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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #53217 +/- ##
================================================
+ Coverage 72.4365% 73.9039% +1.4674%
================================================
Files 1492 1524 +32
Lines 428995 445635 +16640
================================================
+ Hits 310749 329342 +18593
+ Misses 98991 96177 -2814
- Partials 19255 20116 +861
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
rest lgtm except for MDL part, I need more time to learn MDL behaviour 😂
@@ -126,16 +128,98 @@ type SchemaSyncer interface { | |||
// the latest schema version. (exclude the isolated TiDB) | |||
// It returns until all servers' versions are equal to the latest version. | |||
OwnerCheckAllVersions(ctx context.Context, jobID int64, latestVer int64) error | |||
// SyncJobSchemaVerLoop syncs the schema versions on all TiDB nodes for DDL jobs. | |||
SyncJobSchemaVerLoop(ctx context.Context) |
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.
can we move it inside NewSchemaSyncer?
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.
it's part of DDL, start background routines in ddl.Start
should be more clear.
pkg/ddl/syncer/syncer.go
Outdated
v.Lock() | ||
defer v.Unlock() | ||
if ok := fn(v.nodeVersions); !ok { | ||
// onceMatchFn must be nil before. |
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.
maybe move it to function comments, so when I hover the cursor above the function in IDE I can see the comments.
pkg/ddl/syncer/syncer.go
Outdated
s.handleJobSchemaVerKV(oneKV, mvccpb.PUT) | ||
} | ||
s.mu.Lock() | ||
// we might miss some DELETE events during retry, some items might be emptyAndNotUsed, remove them. |
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.
every resp
of line 498 is a snapshot, we can always remove all the old data and apply the resp
, no need to have two removing
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/ddl.go
Outdated
@@ -1205,13 +1233,18 @@ func (d *ddl) DoDDLJob(ctx sessionctx.Context, job *model.Job) error { | |||
recordLastDDLInfo(ctx, historyJob) | |||
}() | |||
i := 0 | |||
notifyCh, ok := d.getJobDoneCh(job.ID) | |||
if !ok { | |||
// shouldn't happen, just give it a dummy one |
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.
it's OK to select from nil
channel https://golangbyexample.com/select-with-nil-channel-golang/
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lance6716, wjhuang2016 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 |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: ref #53246
Problem Summary:
What changed and how does it work?
Check List
Tests
1 pd/3 tikv, 1 tidb. Run on owner node. 20-30% faster
create table
create database
1 pd/3 tikv, 8 tidb. Run on owner node, create table. 42% faster
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.