-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] support async replication (#88)
* support async replication * fix a_sync->async, add async in tests yaml * fix mysync.yaml syntax err * fix docker compose cfg * fix waitForCatchUp return in async mode * set master online on switchover: phase 5 * fix PriorityChoiceMaxLag in async mode * fix queryCalcMdbReplMonTsDelay query * async mode: add tests, fix linters * async mode: add tests, fix linters * async mode: add tests, fix linters * async replication refactoring * async replication test fix * async replication test fix * async replication test fix * async replication test fix * async replication test fix * add mysync-repl-mon feature * add refactor mdb_repl_mon table name to custom configuring name * add refactor mdb_repl_mon table name to custom configuring name * repl_mon fixes * repl_mon fixes * fix typo * add repl_mon tests * fix async tests * fix async tests * fix async tests, add repl_mon.feature launch * fix async tests * fix async tests, fix repl_mon tests * add switch_helper * linters fix * fix " too many arguments " * linters fix * linters fix * linters fix * fix async tests * fix async tests * refactor switch_helper --------- Co-authored-by: suetin <[email protected]> Co-authored-by: teem0n <[email protected]>
- Loading branch information
1 parent
77f1af9
commit 2243d70
Showing
18 changed files
with
735 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/yandex/mysync/internal/mysql" | ||
) | ||
|
||
func (app *App) CheckAsyncSwitchAllowed(node *mysql.Node, switchover *Switchover) bool { | ||
if app.config.ASync && switchover.Cause == CauseAuto && app.config.AsyncAllowedLag > 0 { | ||
app.logger.Infof("async mode is active and this is auto switch so we checking new master delay") | ||
ts, err := app.GetReplMonTS() | ||
if err != nil { | ||
app.logger.Errorf("failed to get mdb repl mon ts: %v", err) | ||
return false | ||
} | ||
delay, err := node.CalcReplMonTSDelay(app.config.ReplMonSchemeName, app.config.ReplMonTableName, ts) | ||
if err != nil { | ||
app.logger.Errorf("failed to calc mdb repl mon ts: %v", err) | ||
return false | ||
} | ||
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 | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func (app *App) updateReplMonTS(master string) error { | ||
masterNode := app.cluster.Get(master) | ||
ts, err := masterNode.GetReplMonTS(app.config.ReplMonSchemeName, app.config.ReplMonTableName) | ||
if err != nil { | ||
return fmt.Errorf("failed to get master repl_mon timestamp: %v", err) | ||
} | ||
return app.SetReplMonTS(ts) | ||
} |
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.