This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
relay: make relay log high available #1291
Merged
Merged
Changes from all commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
24e959c
support TLS in relay
GMHDBJD c62da6b
support gtid in relay
GMHDBJD ec050ee
add relay hub for reader
GMHDBJD b8b9c7c
temp commit
GMHDBJD 0dec4d9
fix nil previous gtid event
GMHDBJD 78fa598
fix nil panic for relay_test
GMHDBJD 34d85df
add ut from relay gtid
GMHDBJD d788eef
change source config for test
GMHDBJD 3923800
change error order
GMHDBJD 0f5433b
revert full-mode config
GMHDBJD 52bfe73
Merge remote-tracking branch 'upstream/master' into relayV2
GMHDBJD 83457ca
fix ut
GMHDBJD f0e7e8c
address comment
GMHDBJD 664b70f
fix sync gtid from oldest file
GMHDBJD 57c83e1
Update pkg/streamer/reader_test.go
GMHDBJD e4b6b77
remove oldest check
GMHDBJD cf32bc6
address comment
GMHDBJD 241e278
support source switch between worker in relay
GMHDBJD 5c6ea46
use random server-id for relay reader
GMHDBJD 3bff78b
use relay log for ha_cases
GMHDBJD d8a77a6
Merge branch 'master' into relayHA
GMHDBJD aae79f9
Merge branch 'master' into relayV2
GMHDBJD aa6cf8c
Merge remote-tracking branch 'upstream/master' into relayV2
GMHDBJD 79cb20e
auto resume for relay
GMHDBJD c07ee7d
fix some bugs
GMHDBJD 632cbf0
enable relay in integration test
GMHDBJD edeb3d8
Merge branch 'relayV2' into relayHA
GMHDBJD 3ead31a
address comment
GMHDBJD 5a69d8c
Merge branch 'relayV2' into relayHA
GMHDBJD 8b024b7
return error if cannot compare gtid
GMHDBJD 056ced5
Merge branch 'relayV2' into relayHA
GMHDBJD bf75c71
use fileReader instead
GMHDBJD e65307b
clear memory relay meta only when init
GMHDBJD a516d55
Merge branch 'relayV2' into relayHA
GMHDBJD 513821e
minor change
GMHDBJD 47d8da2
Merge branch 'relayV2' into relayHA
GMHDBJD 2df59e4
clear meta when reset
GMHDBJD de66815
return error if reach end of file in reader
GMHDBJD bfbc5e2
Merge branch 'relayV2' into relayHA
GMHDBJD cdb3d1f
enable purge relay cmd
GMHDBJD 55b8761
change help_cnt
GMHDBJD f6149da
Merge branch 'master' into relayV2
GMHDBJD d3c4689
remove error comment
GMHDBJD 32de02e
fix some tests
GMHDBJD 4fd723f
fix compatibility test
GMHDBJD 7c863e5
Merge branch 'master' into relayHA
GMHDBJD c5992f3
Merge branch 'master' into relayV2
csuzhangxc 79071d8
Merge remote-tracking branch 'upstream/master' into relayV2
GMHDBJD 65764f1
Merge branch 'master' into relayV2
GMHDBJD 7d662d7
Merge branch 'relayV2' into relayHA
GMHDBJD e444889
add test for resetup meta
GMHDBJD 16a7558
add more comment
GMHDBJD 5e875ab
fix fmt
GMHDBJD e54f231
fix test
GMHDBJD c7a54d7
Merge branch 'master' into relayHA
GMHDBJD 151e97c
relay test for chaos
GMHDBJD 67b928f
minor change
GMHDBJD 76f338d
fix default relay-dir
GMHDBJD 92ef267
fix error log
GMHDBJD f14659f
fix unsupported table option
GMHDBJD 6733785
better arg name
GMHDBJD 00d539d
Merge remote-tracking branch 'upstream/master' into relayHA
GMHDBJD 5506bee
Merge remote-tracking branch 'upstream/master' into relayHA
GMHDBJD b6c19f9
address comment
GMHDBJD 76b7841
fix data race
GMHDBJD 8f7cf97
fix worker not exit
GMHDBJD c1513a6
Merge branch 'master' into relayHA
GMHDBJD eb1c976
Merge branch 'master' into relayHA
csuzhangxc faf371a
address comment
GMHDBJD c45ba2b
unresume some errors
GMHDBJD ae4ad25
Merge branch 'master' into relayHA
GMHDBJD 3543055
fix fmt
GMHDBJD 203310f
Merge branch 'master' into relayHA
GMHDBJD b91fc5f
Merge branch 'master' into relayHA
GMHDBJD 0a58715
Merge remote-tracking branch 'upstream/master' into relayHA
GMHDBJD 10bcb7f
Merge branch 'master' into relayHA
GMHDBJD ef4d21f
revert clone change
GMHDBJD 3f2a346
Merge branch 'master' into relayHA
GMHDBJD db85f8f
revert change of integration test
GMHDBJD 41ef863
fix ci
GMHDBJD 2739495
fix ci
GMHDBJD 61fb37b
add comment
GMHDBJD 3ceabf8
fix ci
GMHDBJD c6bdfd3
fix ci
GMHDBJD b6876f9
fix chaos
GMHDBJD f9c1b1a
increase diff count
GMHDBJD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ var ( | |
keepaliveTime = 3 * time.Second | ||
retryConnectSleepTime = time.Second | ||
syncMasterEndpointsTime = 3 * time.Second | ||
getMinPosForSubTaskFunc = getMinPosForSubTask | ||
getMinLocForSubTaskFunc = getMinLocForSubTask | ||
) | ||
|
||
// Server accepts RPC requests | ||
|
@@ -546,16 +546,24 @@ func (s *Server) startWorker(cfg *config.SourceConfig) error { | |
if cfg.EnableRelay { | ||
dctx, dcancel := context.WithTimeout(s.etcdClient.Ctx(), time.Duration(len(subTaskCfgs))*3*time.Second) | ||
defer dcancel() | ||
minPos, err1 := getMinPosInAllSubTasks(dctx, subTaskCfgs) | ||
minLoc, err1 := getMinLocInAllSubTasks(dctx, subTaskCfgs) | ||
if err1 != nil { | ||
return err1 | ||
} | ||
|
||
// TODO: support GTID | ||
// don't contain GTID information in checkpoint table, just set it to empty | ||
if minPos != nil { | ||
cfg.RelayBinLogName = binlog.AdjustPosition(*minPos).Name | ||
cfg.RelayBinlogGTID = "" | ||
if minLoc != nil { | ||
log.L().Info("get min location in all subtasks", zap.Stringer("location", *minLoc)) | ||
cfg.RelayBinLogName = binlog.AdjustPosition(minLoc.Position).Name | ||
cfg.RelayBinlogGTID = minLoc.GTIDSetStr() | ||
// set UUIDSuffix when bound to a source | ||
cfg.UUIDSuffix, err = binlog.ExtractSuffix(minLoc.Position.Name) | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
// set UUIDSuffix even not checkpoint exist | ||
// so we will still remove relay dir | ||
cfg.UUIDSuffix = binlog.MinUUIDSuffix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
|
||
|
@@ -634,32 +642,31 @@ func makeCommonWorkerResponse(reqErr error) *pb.CommonWorkerResponse { | |
} | ||
|
||
// all subTask in subTaskCfgs should have same source | ||
// this function return the min position in all subtasks, used for relay's position | ||
// TODO: get min gtidSet | ||
func getMinPosInAllSubTasks(ctx context.Context, subTaskCfgs []*config.SubTaskConfig) (minPos *mysql.Position, err error) { | ||
// this function return the min location in all subtasks, used for relay's location | ||
func getMinLocInAllSubTasks(ctx context.Context, subTaskCfgs []*config.SubTaskConfig) (minLoc *binlog.Location, err error) { | ||
for _, subTaskCfg := range subTaskCfgs { | ||
pos, err := getMinPosForSubTaskFunc(ctx, subTaskCfg) | ||
loc, err := getMinLocForSubTaskFunc(ctx, subTaskCfg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if pos == nil { | ||
if loc == nil { | ||
continue | ||
} | ||
|
||
if minPos == nil { | ||
minPos = pos | ||
if minLoc == nil { | ||
minLoc = loc | ||
} else { | ||
if minPos.Compare(*pos) >= 1 { | ||
minPos = pos | ||
if binlog.CompareLocation(*minLoc, *loc, subTaskCfg.EnableGTID) >= 1 { | ||
minLoc = loc | ||
} | ||
} | ||
} | ||
|
||
return minPos, nil | ||
return minLoc, nil | ||
} | ||
|
||
func getMinPosForSubTask(ctx context.Context, subTaskCfg *config.SubTaskConfig) (minPos *mysql.Position, err error) { | ||
func getMinLocForSubTask(ctx context.Context, subTaskCfg *config.SubTaskConfig) (minLoc *binlog.Location, err error) { | ||
if subTaskCfg.Mode == config.ModeFull { | ||
return nil, nil | ||
} | ||
|
@@ -682,7 +689,7 @@ func getMinPosForSubTask(ctx context.Context, subTaskCfg *config.SubTaskConfig) | |
} | ||
|
||
location := checkpoint.GlobalPoint() | ||
return &location.Position, nil | ||
return &location, nil | ||
} | ||
|
||
// unifyMasterBinlogPos eliminates different masterBinlog in one response | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 may update the GitHub actions workflow and these config files to enable/disable both for
enable-gtid
andenable-relay
later.