diff --git a/internal/app/async.go b/internal/app/async.go index 65c8139b..f1b63245 100644 --- a/internal/app/async.go +++ b/internal/app/async.go @@ -34,4 +34,4 @@ func (app *App) updateReplMonTS(master string) error { return fmt.Errorf("failed to get master repl_mon timestamp: %v", err) } return app.SetReplMonTS(ts) -} \ No newline at end of file +} diff --git a/internal/config/config.go b/internal/config/config.go index 6725cc6b..b27bc3c6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -91,11 +91,11 @@ type Config struct { ASync bool `config:"async" yaml:"async"` AsyncAllowedLag int64 `config:"async_allowed_lag" yaml:"async_allowed_lag"` ReplMon bool `config:"repl_mon" yaml:"repl_mon"` - ReplMonSchemeName string `config:"repl_mon_scheme_name" yaml:"repl_mon_scheme_name"` - ReplMonTableName string `config:"repl_mon_table_name" yaml:"repl_mon_table_name"` - ReplMonWriteInterval time.Duration `config:"repl_mon_write_interval" yaml:"repl_mon_write_interval"` - ReplMonErrorWaitInterval time.Duration `config:"repl_mon_error_wait_interval" yaml:"repl_mon_error_wait_interval"` - ReplMonSlaveWaitInterval time.Duration `config:"repl_mon_slave_wait_interval" yaml:"repl_mon_slave_wait_interval"` + ReplMonSchemeName string `config:"repl_mon_scheme_name" yaml:"repl_mon_scheme_name"` + ReplMonTableName string `config:"repl_mon_table_name" yaml:"repl_mon_table_name"` + ReplMonWriteInterval time.Duration `config:"repl_mon_write_interval" yaml:"repl_mon_write_interval"` + ReplMonErrorWaitInterval time.Duration `config:"repl_mon_error_wait_interval" yaml:"repl_mon_error_wait_interval"` + ReplMonSlaveWaitInterval time.Duration `config:"repl_mon_slave_wait_interval" yaml:"repl_mon_slave_wait_interval"` } // DefaultConfig returns default configuration for MySync @@ -174,12 +174,12 @@ func DefaultConfig() (Config, error) { ExternalReplicationType: util.Disabled, ASync: false, AsyncAllowedLag: 0, - ReplMon: false, - ReplMonSchemeName: "mysql", - ReplMonTableName: "mysync_repl_mon", - ReplMonWriteInterval: 1 * time.Second, - ReplMonErrorWaitInterval: 10 * time.Second, - ReplMonSlaveWaitInterval: 10 * time.Second, + ReplMon: false, + ReplMonSchemeName: "mysql", + ReplMonTableName: "mysync_repl_mon", + ReplMonWriteInterval: 1 * time.Second, + ReplMonErrorWaitInterval: 10 * time.Second, + ReplMonSlaveWaitInterval: 10 * time.Second, } return config, nil } diff --git a/internal/mysql/node.go b/internal/mysql/node.go index b4262565..727c893b 100644 --- a/internal/mysql/node.go +++ b/internal/mysql/node.go @@ -1015,7 +1015,7 @@ func (n *Node) GetReplMonTS(replMonSchemeName string, replMonTable string) (stri err := n.queryRowMogrify(queryGetReplMonTS, map[string]interface{}{ "replMonSchemeName": schemaname(replMonSchemeName), - "replMonTable": schemaname(replMonTable), + "replMonTable": schemaname(replMonTable), }, result) return result.Timestamp, err @@ -1025,9 +1025,9 @@ func (n *Node) CalcReplMonTSDelay(replMonSchemeName string, replMonTable string, result := new(ReplMonTSDelay) err := n.queryRowMogrify(queryCalcReplMonTSDelay, map[string]interface{}{ - "ts": ts, + "ts": ts, "replMonSchemeName": schemaname(replMonSchemeName), - "replMonTable": schemaname(replMonTable), + "replMonTable": schemaname(replMonTable), }, result) return result.Delay, err @@ -1036,13 +1036,13 @@ func (n *Node) CalcReplMonTSDelay(replMonSchemeName string, replMonTable string, func (n *Node) CreateReplMonTable(replMonSchemeName string, replMonTable string) error { return n.execMogrify(queryCreateReplMonTable, map[string]interface{}{ "replMonSchemeName": schemaname(replMonSchemeName), - "replMonTable": schemaname(replMonTable), + "replMonTable": schemaname(replMonTable), }) } func (n *Node) UpdateReplMonTable(replMonSchemeName string, replMonTable string) error { return n.execMogrify(queryUpdateReplMon, map[string]interface{}{ "replMonSchemeName": schemaname(replMonSchemeName), - "replMonTable": schemaname(replMonTable), + "replMonTable": schemaname(replMonTable), }) -} \ No newline at end of file +} diff --git a/internal/mysql/queries.go b/internal/mysql/queries.go index 6f5f39f6..d2f3cafc 100644 --- a/internal/mysql/queries.go +++ b/internal/mysql/queries.go @@ -46,10 +46,10 @@ const ( querySetInnodbFlushLogAtTrxCommit = "set_innodb_flush_log_at_trx_commit" querySetSyncBinlog = "set_sync_binlog" queryGetReplicationSettings = "get_replication_settings" - queryGetReplMonTS = "get_repl_mon_ts" - queryCalcReplMonTSDelay = "calc_repl_mon_ts_delay" - queryCreateReplMonTable = "create_repl_mon_table" - queryUpdateReplMon = "update_repl_mon" + queryGetReplMonTS = "get_repl_mon_ts" + queryCalcReplMonTSDelay = "calc_repl_mon_ts_delay" + queryCreateReplMonTable = "create_repl_mon_table" + queryUpdateReplMon = "update_repl_mon" ) var DefaultQueries = map[string]string{ @@ -129,14 +129,14 @@ 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`, - queryGetReplMonTS: `SELECT UNIX_TIMESTAMP(ts) AS ts FROM :replMonSchemeName.:replMonTable`, - queryCalcReplMonTSDelay: `SELECT FLOOR(CAST(:ts AS DECIMAL(20,3)) - UNIX_TIMESTAMP(ts)) AS delay FROM :replMonSchemeName.:replMonTable`, - queryCreateReplMonTable: `CREATE TABLE IF NOT EXISTS :replMonSchemeName.:replMonTable( + queryGetReplMonTS: `SELECT UNIX_TIMESTAMP(ts) AS ts FROM :replMonSchemeName.:replMonTable`, + queryCalcReplMonTSDelay: `SELECT FLOOR(CAST(:ts AS DECIMAL(20,3)) - UNIX_TIMESTAMP(ts)) AS delay FROM :replMonSchemeName.:replMonTable`, + queryCreateReplMonTable: `CREATE TABLE IF NOT EXISTS :replMonSchemeName.:replMonTable( id INT NOT NULL PRIMARY KEY, ts TIMESTAMP(3) ) ENGINE=INNODB`, - queryUpdateReplMon: `INSERT INTO :replMonSchemeName.:replMonTable(id, ts) + queryUpdateReplMon: `INSERT INTO :replMonSchemeName.:replMonTable(id, ts) ( SELECT 1, CURRENT_TIMESTAMP(3) WHERE @@read_only = 0