-
Notifications
You must be signed in to change notification settings - Fork 188
syncer: fix syncer gtid auto switch from off to on #1723
Conversation
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 review later
Is the test case needed to be added to other_integrations.txt?
@@ -254,8 +254,10 @@ func (s *Server) doStartKeepAlive() { | |||
} | |||
|
|||
func (s *Server) stopKeepAlive() { | |||
s.kaCancel() | |||
s.kaWg.Wait() | |||
if s.kaCancel != 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.
in which case stopKeepAlive
is called before or concurrent with startKeepAlive
? we may need a lock if so 😂
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-worker/main.go
s.Start()
- Start() return an error before
s.startKeepAlive()
. e.g.: worker port already in use - dm-worker/main.go
s.Close()
->s.stopKeepAlive()
, report a nil pointer info in stdout
pkg/binlog/position.go
Outdated
if cmp = compareIndex(location1.Suffix, location2.Suffix); cmp != 0 { | ||
return cmp | ||
} | ||
if location1.gtidSet != nil && location1.gtidSet.String() != "" { | ||
return cmp | ||
} |
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 if both gtid sets are empty, but suffix are not? e.g. location1:(pos1,"",1), location2:(pos2,"",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.
I think Suffix
is only used in handle-error
?
check_checkpoint $SOURCE_ID1 $name1 $pos1 $gtid1 | ||
check_checkpoint $SOURCE_ID2 $name2 $pos2 $gtid2 | ||
dmctl_stop_task_with_retry $TASK_NAME $MASTER_PORT | ||
clean_gtid |
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 start a source without gtid and than restart with gtid closer to the user scenario? Moreover, adjust gtid in relay seems not be implemented and tested in this 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.
- I think cleaning gtid data is the same. Operation source again is a little complicated so I use this way to simplify the test.
- adjust GTID in relay will be implemented in the next PR
tests/adjust_gtid/run.sh
Outdated
dmctl_stop_task_with_retry $TASK_NAME $MASTER_PORT | ||
clean_gtid | ||
|
||
export GO_FAILPOINTS='github.com/pingcap/dm/syncer/AdjustGTIDExit=return(true)' |
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.
dumplicate export
/run-all-tests |
cmd/dm-worker/main_test.go
Outdated
@@ -56,6 +56,7 @@ func TestRunMain(_ *testing.T) { | |||
defer func() { utils.OsExit = oldOsExit }() | |||
utils.OsExit = func(code int) { | |||
log.L().Info("os exits", zap.Int("exit code", code)) | |||
_ = utils.KillMySelf() |
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 can't remember why we need this helper function now. maybe the process won't exit after this test function returns?
if so, I think the reason may be that lthe test function should be named TestMain
not TestRunMain
, please check if this works.
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.
cmd/dm-worker/main_test.go
Outdated
@@ -56,6 +56,7 @@ func TestRunMain(_ *testing.T) { | |||
defer func() { utils.OsExit = oldOsExit }() | |||
utils.OsExit = func(code int) { | |||
log.L().Info("os exits", zap.Int("exit code", code)) | |||
_ = utils.KillMySelf() |
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.
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
pkg/binlog/reader/util.go
Outdated
defer r.Close() | ||
|
||
// GetGTIDsForPosStreamer tries to get GTID sets for the specified binlog position (for the corresponding txn) from a Streamer. | ||
func GetGTIDsForPosStreamer(ctx context.Context, r Streamer, endPos gmysql.Position) (gtid.Set, error) { |
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.
func GetGTIDsForPosStreamer(ctx context.Context, r Streamer, endPos gmysql.Position) (gtid.Set, error) { | |
func GetGTIDsForPosFromStreamer(ctx context.Context, r Streamer, endPos gmysql.Position) (gtid.Set, error) { |
syncer/checkpoint.go
Outdated
@@ -781,7 +781,8 @@ func (cp *RemoteCheckPoint) Load(tctx *tcontext.Context) error { | |||
gset, | |||
) | |||
if isGlobal { | |||
if binlog.CompareLocation(location, binlog.NewLocation(cp.cfg.Flavor), cp.cfg.EnableGTID) > 0 { | |||
// Use CompareLocationAsPossible here to make sure checkpoint can be updated if gset is empty | |||
if binlog.CompareLocationAsPossible(location, binlog.NewLocation(cp.cfg.Flavor), cp.cfg.EnableGTID) > 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.
Does this function always called with location2 as empty location? If so, we could not be bothered to add an unit test, just simplifying the logic and tighten function name
/lgtm |
@GMHDBJD: Please use GitHub review feature instead of For the reason we drop support to the commands, see also this page. 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. |
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.
/lgtm
@GMHDBJD: Please use GitHub review feature instead of For the reason we drop support to the commands, see also this page. 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. |
[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. |
add require-LGT1 for GMHDBJD |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 4c39ddf
|
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.
LGTM
In response to a cherrypick label: new pull request created: #1745. |
What problem does this PR solve?
#1586 part 1
What is changed and how it works?
Add auto adjust gtid before we start a task.
Check List
Tests
Code changes
Side effects
Related changes