-
Notifications
You must be signed in to change notification settings - Fork 18
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
support async replication #88
Merged
Merged
Changes from 11 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
55dd18b
support async replication
4dfafc3
fix a_sync->async, add async in tests yaml
afefe5c
fix mysync.yaml syntax err
3a4dcb0
fix docker compose cfg
62a430a
fix waitForCatchUp return in async mode
71f4403
set master online on switchover: phase 5
091024c
fix PriorityChoiceMaxLag in async mode
b685481
fix queryCalcMdbReplMonTsDelay query
2bfb126
async mode: add tests, fix linters
e88784d
async mode: add tests, fix linters
a155b32
async mode: add tests, fix linters
27b7834
async replication refactoring
00bdd06
async replication test fix
81a0f60
async replication test fix
3f44fc7
async replication test fix
c741698
Merge branch 'master' into async-replication
teem0n 9b8d7a3
async replication test fix
302ff31
Merge branch 'async-replication' of github.com:yandex/mysync into asy…
b8a90db
async replication test fix
7425ad9
add mysync-repl-mon feature
3481208
add refactor mdb_repl_mon table name to custom configuring name
51782c9
add refactor mdb_repl_mon table name to custom configuring name
6f9a218
repl_mon fixes
5efe22e
repl_mon fixes
928e140
fix typo
de6a36e
add repl_mon tests
26efe42
fix async tests
9e9a083
fix async tests
7a878b3
fix async tests, add repl_mon.feature launch
4faacd9
fix async tests
428b272
fix async tests, fix repl_mon tests
31cfffb
add switch_helper
b7b0b32
linters fix
c5e08fb
fix " too many arguments "
68c8a96
linters fix
2de37a7
linters fix
24f2840
linters fix
7fddbdd
Merge branch 'master' into async-replication
teem0n d9ba04f
Merge branch 'master' into async-replication
teem0n 9fd2bd6
Merge branch 'master' into async-replication
teem0n 723d4db
fix async tests
1468bb5
fix async tests
6937a8b
refactor switch_helper
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -700,6 +700,11 @@ func (app *App) stateManager() appState { | |
app.logger.Errorf("failed to update active nodes in dcs: %v", err) | ||
} | ||
|
||
err = app.updateMdbReplMonTS(master) | ||
if err != nil { | ||
app.logger.Errorf("failed to update mdb_repl_mon timestamp: %v", err) | ||
} | ||
|
||
return stateManager | ||
} | ||
|
||
|
@@ -1218,8 +1223,13 @@ func (app *App) performSwitchover(clusterState map[string]*NodeState, activeNode | |
newMaster = switchover.To | ||
} else if switchover.From != "" { | ||
positions2 := filterOutNodeFromPositions(positions, switchover.From) | ||
PriorityChoiceMaxLag := app.config.PriorityChoiceMaxLag | ||
AsyncAllowedLagTime := time.Duration(app.config.AsyncAllowedLag) * time.Second | ||
if app.config.ASync && switchover.Cause == CauseAuto && AsyncAllowedLagTime > app.config.PriorityChoiceMaxLag { | ||
PriorityChoiceMaxLag = AsyncAllowedLagTime | ||
} | ||
// we ignore splitbrain flag as it should be handled during searching most recent host | ||
newMaster, err = getMostDesirableNode(app.logger, positions2, app.config.PriorityChoiceMaxLag) | ||
newMaster, err = getMostDesirableNode(app.logger, positions2, PriorityChoiceMaxLag) | ||
if err != nil { | ||
return fmt.Errorf("switchover: error while looking for highest priority node: %s", switchover.From) | ||
} | ||
|
@@ -1270,6 +1280,10 @@ func (app *App) performSwitchover(clusterState map[string]*NodeState, activeNode | |
|
||
// turn slaves to the new master | ||
app.logger.Info("switchover: phase 5: turn to the new master") | ||
err = app.cluster.Get(newMaster).SetOnline() | ||
if err != nil { | ||
return fmt.Errorf("got error on setting new master %s online %v", newMaster, err) | ||
} | ||
errs = util.RunParallel(func(host string) error { | ||
if host == newMaster || !clusterState[host].PingOk { | ||
return nil | ||
|
@@ -2118,9 +2132,28 @@ func (app *App) waitForCatchUp(node *mysql.Node, gtidset gtids.GTIDSet, timeout | |
if gtidExecuted.Contain(gtidset) { | ||
return true, nil | ||
} | ||
if app.dcs.Get(pathCurrentSwitch, new(Switchover)) == dcs.ErrNotFound { | ||
switchover := new(Switchover) | ||
if app.dcs.Get(pathCurrentSwitch, switchover) == dcs.ErrNotFound { | ||
return false, nil | ||
} | ||
if app.config.ASync && switchover.Cause == CauseAuto { | ||
app.logger.Infof("async mode is active and this is auto switch so we checking new master delay") | ||
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. May be we should move this to async file? |
||
ts, err := app.GetMdbReplMonTS() | ||
if err != nil { | ||
app.logger.Errorf("failed to get mdb repl mon ts: %v", err) | ||
continue | ||
} | ||
delay, err := node.CalcMdbReplMonTSDelay(ts) | ||
if err != nil { | ||
app.logger.Errorf("failed to calc mdb repl mon ts: %v", err) | ||
continue | ||
} | ||
if delay < app.config.AsyncAllowedLag { | ||
app.logger.Infof("async allowed lag is %d and current lag on host %s is %d, so we don't wait for catch up any more", | ||
app.config.AsyncAllowedLag, node.Host(), delay) | ||
return true, nil | ||
} | ||
} | ||
time.Sleep(sleep) | ||
if time.Now().After(deadline) { | ||
break | ||
|
@@ -2224,6 +2257,15 @@ func (app *App) getNodePositions(activeNodes []string) ([]nodePosition, error) { | |
return positions, util.CombineErrors(errs) | ||
} | ||
|
||
func (app *App) updateMdbReplMonTS(master string) error { | ||
masterNode := app.cluster.Get(master) | ||
ts, err := masterNode.GetMdbReplMonTS() | ||
if err != nil { | ||
return fmt.Errorf("failed to get master mdb_repl_mon timestamp: %v", err) | ||
} | ||
return app.SetMdbReplMonTS(ts) | ||
} | ||
|
||
/* | ||
Run enters the main application loop | ||
When Run exits mysync process is over | ||
|
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
Oops, something went wrong.
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 should explicitly mention "in dcs"