-
Notifications
You must be signed in to change notification settings - Fork 283
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
syncer(dm): init schemaTracker when syncer run #6052
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/area dm |
/run-dm-integration-test |
This comment was marked as resolved.
This comment was marked as resolved.
The schemaTracker can still be tiflow/dm/pkg/schema/tracker.go Line 400 in 9035b2f
|
/run-dm-integration-test |
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.
And also can we add a test of "two tracker"?
rest lgtm
dm/pkg/schema/tracker.go
Outdated
@@ -99,16 +99,25 @@ type DownstreamTableInfo struct { | |||
WhereHandle *sqlmodel.WhereHandle | |||
} | |||
|
|||
// NewTracker creates a new tracker. `sessionCfg` will be set as tracker's session variables if specified, or retrieve | |||
// NewDumpTracker simply returns an empty Tracker, |
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.
what's the meaning of Dump? Syncer can run without dump unit.
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.
Will rename 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.
dm/syncer/syncer.go
Outdated
@@ -1696,7 +1698,13 @@ func (s *Syncer) Run(ctx context.Context) (err error) { | |||
} | |||
} | |||
|
|||
s.schemaTracker, err = schema.NewTracker(ctx, s.cfg.Name, s.cfg.To.Session, s.downstreamTrackConn, s.tctx.L()) | |||
if s.schemaTracker == nil { | |||
s.schemaTracker, err = schema.NewTracker(ctx, s.cfg.Name, s.cfg.To.Session, s.downstreamTrackConn, s.tctx.L()) |
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.
this is only to make test happy? we can left a comment
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.
Yes. some tests set the schemaTracker themselves. Will leave a comment.
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.
/cc @D3Hunter |
ctx context.Context, | ||
task string, | ||
sessionCfg map[string]string, | ||
downstreamConn *dbconn.DBConn, | ||
logger log.Logger, | ||
) (*Tracker, error) { | ||
) error { | ||
if tr == nil { |
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 will tr be nil?
if it's for test, we can change test instead
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.
This line is copied from the old version. I remember it will let the load_task
IT fail if deleted (probably this test case tries to pause-task
before initializing the syncer). will take a look tomorrow.
dm/pkg/schema/tracker.go
Outdated
dsTracker: dsTracker, | ||
}, nil | ||
// NewTracker creates a new tracker. It's preserved for test. | ||
func NewTracker( |
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.
prefer to name NewDumpTracker
as NewTracker
, and remove this one.
for test, we change them to Init
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 leaving a function invoking NewTracker
and subsequently Init
is better, so as to make the test more succinct.
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.
then name it explicitly as something like NewTrackerForTest. NewTracker
is how we name normal ctor
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.
IDE should be able to easily rename them all
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.
/run-dm-integration-test |
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## master #6052 +/- ##
================================================
- Coverage 57.2815% 54.1204% -3.1612%
================================================
Files 680 399 -281
Lines 80230 50055 -30175
================================================
- Hits 45957 27090 -18867
+ Misses 30009 20302 -9707
+ Partials 4264 2663 -1601 |
tr.Lock() | ||
defer tr.Unlock() |
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 this lock is used in 3 places, please refine comments in Tracker
definition
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.
/run-verify |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 77cfbca
|
/run-dm-integration-test |
/run-dm-integration-test |
/run-dm-integration-test |
) * syncer(dm): init schemaTracker when syncer run (#6052) close #6014 * cdc: upgrade pebble and stabilize a case (#6116) close #5798 * meta(engine): Resourcemeta support job level isolation (#5817) close #5816 * owner(cdc): clean up admin jobs on async close (#6129) close #6128 * pkg/errctx(engine): avoid creating goroutinue in errctx (#6061) ref #6013 * cdc,pkg: accommodate systemd TimeoutStopSec and k8s terminationGracePeriodSeconds (#6097) * cdc,pkg: accommodate systemd TimeoutStopSec and k8s terminationGracePeriodSeconds * cdc: correct drain capture doc Signed-off-by: Neil Shen <[email protected]> * cdc: drain waits for owner resign and table move out Signed-off-by: Neil Shen <[email protected]> * tp(cdc): make drain capture scheduler aware of capture state Signed-off-by: Neil Shen <[email protected]> * cdc: remove verbose log and set liveness stop after resign owner Signed-off-by: Neil Shen <[email protected]> * cdc: skip owner resign when there is only one capture Signed-off-by: Neil Shen <[email protected]> * fix ut * apply comments * fix integration test * fix lint Co-authored-by: Obliviate <[email protected]> Co-authored-by: qupeng <[email protected]> Co-authored-by: maxshuang <[email protected]> Co-authored-by: Neil Shen <[email protected]> Co-authored-by: Yujie Xia <[email protected]>
What problem does this PR solve?
Issue Number: close #6014
What is changed and how it works?
The validator will get the old schemaTracker because the syncer re-builds the schemaTracker every time it starts. To avoid that, I'm about to decouple the creating and initialization of the schemaTracker so that the syncer will only initialize the schemaTracker when it starts to run and the schemaTracker remains the same instance in the whole lifecycle of the task.
Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note