Skip to content
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 43 commits into from
Jun 17, 2024
Merged

support async replication #88

merged 43 commits into from
Jun 17, 2024

Conversation

moridin26
Copy link
Contributor

No description provided.

@moridin26 moridin26 changed the title WIP support async replication [WIP] support async replication Mar 16, 2024
@@ -88,6 +88,8 @@ type Config struct {
ReplicationChannel string `config:"replication_channel" yaml:"replication_channel"`
ExternalReplicationChannel string `config:"external_replication_channel" yaml:"external_replication_channel"`
ExternalReplicationType util.ExternalReplicationType `config:"external_replication_type" yaml:"external_replication_type"`
ASync bool `config:"a_sync" yaml:"a_sync"`
ASyncAllowedLag int64 `config:"a_sync_allowed_lag" yaml:"a_sync_allowed_lag"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a_sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New setting which will allow client to set server in async mode. In async mode in case of failover mysync will promote slave to new master even if it has replication delay, but only if delay less then ASyncAllowedLag

@@ -123,4 +125,6 @@ var DefaultQueries = map[string]string{
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`,
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 replication_applier_status_by_worker table OR move mdb_repl_mon to mysync.

@@ -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)
Copy link
Contributor

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"

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we should move this to async file?

@teem0n teem0n merged commit 2243d70 into master Jun 17, 2024
52 checks passed
@teem0n teem0n deleted the async-replication branch June 17, 2024 08:00
@moridin26 moridin26 changed the title [WIP] support async replication support async replication Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants