-
Notifications
You must be signed in to change notification settings - Fork 16
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
Changes from 5 commits
55dd18b
4dfafc3
afefe5c
3a4dcb0
62a430a
71f4403
091024c
b685481
2bfb126
e88784d
a155b32
27b7834
00bdd06
81a0f60
3f44fc7
c741698
9b8d7a3
302ff31
b8a90db
7425ad9
3481208
51782c9
6f9a218
5efe22e
928e140
de6a36e
26efe42
9e9a083
7a878b3
4faacd9
428b272
31cfffb
b7b0b32
c5e08fb
68c8a96
2de37a7
24f2840
7fddbdd
d9ba04f
9fd2bd6
723d4db
1468bb5
6937a8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -700,6 +700,11 @@ | |
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 | ||
} | ||
|
||
|
@@ -2118,9 +2123,28 @@ | |
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 +2248,15 @@ | |
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,8 @@ | |
querySetInnodbFlushLogAtTrxCommit = "set_innodb_flush_log_at_trx_commit" | ||
querySetSyncBinlog = "set_sync_binlog" | ||
queryGetReplicationSettings = "get_replication_settings" | ||
queryGetMdbReplMonTs = "get_mdb_repl_mon_ts" | ||
queryCalcMdbReplMonTsDelay = "calc_mdb_repl_mon_ts_delay" | ||
) | ||
|
||
var DefaultQueries = map[string]string{ | ||
|
@@ -123,4 +125,6 @@ | |
querySetInnodbFlushLogAtTrxCommit: `SET GLOBAL innodb_flush_log_at_trx_commit = :level`, | ||
queryGetReplicationSettings: `SELECT @@innodb_flush_log_at_trx_commit as InnodbFlushLogAtTrxCommit, @@sync_binlog as SyncBinlog`, | ||
querySetSyncBinlog: `SET GLOBAL sync_binlog = :sync_binlog`, | ||
queryGetMdbReplMonTs: `SELECT UNIX_TIMESTAMP(ts) AS ts FROM mysql.mdb_repl_mon`, | ||
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. This one looks very specific to your installation. Probably, we should use data from |
||
queryCalcMdbReplMonTsDelay: `SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP(0)) - CAST(:ts AS DECIMAL(20,0)) AS delay`, | ||
} |
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"