From 866cd88732452b13cd572ee317bb466760619642 Mon Sep 17 00:00:00 2001 From: Kamil Holubicki Date: Thu, 27 Jan 2022 10:27:46 +0100 Subject: [PATCH] issue-1423: cluster-osc-slaves API may not return all required slaves https://github.com/openark/orchestrator/issues/1423 The new algorithm implemented: Stage 1: 1st tier servers. Get up to two 1st tier servers from each DC in the following order: Most busiest IMs Most lagging leaf nodes Examples: If there are N > 1 IMs in the DC, we will use the 2 busiest ones (having the highest number of replicas) If there is only 1 IM in the DC, but there are some leaf nodes, we will use IM + most lagging leaf node If there are no IMs in the DC, but there are leaf nodes, we will use up to two most lagging leaf nodes So this stage will collect at most 2 servers per DC Stage 2: 2nd tier servers Examine all collected 1st tier servers (from Stage 1), and if they are IMs, get at most two busiest replicas for each server (2nd tier servers). So this stage will collect at most 2 replicas per IM. If we collected 2 IMs per DC in Stage 1, here we will get 4 servers per DC. Stage 3: 3rd tier servers Get 2 busiest 3rd tier replicas per DC. If replicas are leaves we get the replica with a larger lag. So this stage will collect at most 2 servers per DC Added new tests 'get-heuristic-lag-multi-dc' and 'which-cluster-ocs-replicas' --- go/inst/instance_dao.go | 134 +++++++++++------- .../create.sql | 124 ++++++++++++++++ .../expect_output | 1 + .../extra_args | 1 + .../which-cluster-ocs-replicas/create.sql | 124 ++++++++++++++++ .../which-cluster-ocs-replicas/expect_output | 14 ++ .../which-cluster-ocs-replicas/extra_args | 1 + 7 files changed, 350 insertions(+), 49 deletions(-) create mode 100644 tests/integration/get-cluster-heuristic-lag-multi-dc/create.sql create mode 100644 tests/integration/get-cluster-heuristic-lag-multi-dc/expect_output create mode 100644 tests/integration/get-cluster-heuristic-lag-multi-dc/extra_args create mode 100644 tests/integration/which-cluster-ocs-replicas/create.sql create mode 100644 tests/integration/which-cluster-ocs-replicas/expect_output create mode 100644 tests/integration/which-cluster-ocs-replicas/extra_args diff --git a/go/inst/instance_dao.go b/go/inst/instance_dao.go index 63324c749..1e1da4a3b 100644 --- a/go/inst/instance_dao.go +++ b/go/inst/instance_dao.go @@ -68,6 +68,30 @@ func (this InstancesByCountReplicas) Less(i, j int) bool { return len(this[i].Replicas) < len(this[j].Replicas) } +// InstancesByDc is a sortable type for Instance +// 1. Instances are sorted by DC +// 2. Within DC group instances are sorted by replicas count +// 3. Within ReplicasCount group insances are: +// a) not sorted if ReplicasCount > 0 +// b) sorted by replication lag if ReplicasCount == 0 +// +// DC1 < DC2 +// if DC1 == DC2 => len(Replicas1) < len (Replicas2) +// if Replicas.cnt == 0 => replicationLag1 < replicatonLag2 +type InstancesByDc [](*Instance) + +func (this InstancesByDc) Len() int { return len(this) } +func (this InstancesByDc) Swap(i, j int) { this[i], this[j] = this[j], this[i] } +func (this InstancesByDc) Less(i, j int) bool { + if this[i].DataCenter == this[j].DataCenter { + if len(this[i].Replicas) == 0 && len(this[j].Replicas) == 0 { + return this[i].ReplicationLagSeconds.Int64 < this[j].ReplicationLagSeconds.Int64 + } + return len(this[i].Replicas) < len(this[j].Replicas) + } + return (this[i].DataCenter < this[j].DataCenter) +} + // Constant strings for Group Replication information // See https://dev.mysql.com/doc/refman/8.0/en/replication-group-members-table.html for additional information. const ( @@ -1665,36 +1689,78 @@ func filterOSCInstances(instances [](*Instance)) [](*Instance) { return result } +// Get two busiest instances per DC +func getTwoBusiestPerDC(all [](*Instance)) [](*Instance) { + result := [](*Instance){} + + // sort by DC and replicas count + sort.Sort(sort.Reverse(InstancesByDc(all))) + + currentDCInstances := 0 + var currentDC *string = nil + + for _, im := range all { + if currentDC == nil || *currentDC != im.DataCenter { + currentDCInstances = 0 + currentDC = &im.DataCenter + } + if currentDCInstances > 1 { + continue + } + currentDCInstances++ + result = append(result, im) + } + return result +} + // GetClusterOSCReplicas returns a heuristic list of replicas which are fit as controll replicas for an OSC operation. // These would be intermediate masters func GetClusterOSCReplicas(clusterName string) ([](*Instance), error) { - intermediateMasters := [](*Instance){} - result := [](*Instance){} - var err error - if strings.Index(clusterName, "'") >= 0 { + if strings.Contains(clusterName, "'") { return [](*Instance){}, log.Errorf("Invalid cluster name: %s", clusterName) } + + result := [](*Instance){} + // Stage 1: 1st tier servers. + // We get up to two 1st tier servers from each DC in the following order: + // 1. Most busiest IMs + // 2. Most lagging leaf nodes + // Examples: + // 1. If there are N > 1 IMs in the DC, we will use 2 busiest ones + // (having the highest number of replicas) + // 2. If there is only 1 IM in the DC, but there are some leaf nodes, + // we will use IM + most lagging leaf node + // 3. If there are no IMs in the DC, but there are leaf nodes, we will use + // up to two most lagging leaf nodes + // + // So this stage will collect at most 2 servers per DC { - // Pick up to two busiest IMs condition := ` replication_depth = 1 - and num_slave_hosts > 0 and cluster_name = ? ` - intermediateMasters, err = readInstancesByCondition(condition, sqlutils.Args(clusterName), "") + firstTierServers, err := readInstancesByCondition(condition, sqlutils.Args(clusterName), "") if err != nil { return result, err } - sort.Sort(sort.Reverse(InstancesByCountReplicas(intermediateMasters))) - intermediateMasters = filterOSCInstances(intermediateMasters) - intermediateMasters = intermediateMasters[0:math.MinInt(2, len(intermediateMasters))] - result = append(result, intermediateMasters...) + + firstTierServers = filterOSCInstances(firstTierServers) + result = append(result, getTwoBusiestPerDC(firstTierServers)...) } + + // Stage 2: 2nd tier servers + // Examine all selected 1st tier servers, and if they are IMs, get at most + // two of their busiest replicas (2nd tier servers). + // So this stage will collect at most 2 replicas per IM. If we collected 2 IMs + // per DC in the 1st stage, here we will get 4 servers per DC { - // Get 2 replicas of found IMs, if possible - if len(intermediateMasters) == 1 { - // Pick 2 replicas for this IM - replicas, err := ReadReplicaInstances(&(intermediateMasters[0].Key)) + // Get at most 2 replicas of found IMs + for _, im := range result { + if len(im.Replicas) == 0 { + // this is 1st tier leaf + continue + } + replicas, err := ReadReplicaInstances(&im.Key) if err != nil { return result, err } @@ -1702,25 +1768,12 @@ func GetClusterOSCReplicas(clusterName string) ([](*Instance), error) { replicas = filterOSCInstances(replicas) replicas = replicas[0:math.MinInt(2, len(replicas))] result = append(result, replicas...) - } - if len(intermediateMasters) == 2 { - // Pick one replica from each IM (should be possible) - for _, im := range intermediateMasters { - replicas, err := ReadReplicaInstances(&im.Key) - if err != nil { - return result, err - } - sort.Sort(sort.Reverse(InstancesByCountReplicas(replicas))) - replicas = filterOSCInstances(replicas) - if len(replicas) > 0 { - result = append(result, replicas[0]) } - } - } - } + + // Stage 3: 3rd tier servers + // Get 2 busiest 3rd tier replicas per DC { - // Get 2 3rd tier replicas, if possible condition := ` replication_depth = 3 and cluster_name = ? @@ -1729,25 +1782,8 @@ func GetClusterOSCReplicas(clusterName string) ([](*Instance), error) { if err != nil { return result, err } - sort.Sort(sort.Reverse(InstancesByCountReplicas(replicas))) - replicas = filterOSCInstances(replicas) - replicas = replicas[0:math.MinInt(2, len(replicas))] - result = append(result, replicas...) - } - { - // Get 2 1st tier leaf replicas, if possible - condition := ` - replication_depth = 1 - and num_slave_hosts = 0 - and cluster_name = ? - ` - replicas, err := readInstancesByCondition(condition, sqlutils.Args(clusterName), "") - if err != nil { - return result, err - } replicas = filterOSCInstances(replicas) - replicas = replicas[0:math.MinInt(2, len(replicas))] - result = append(result, replicas...) + result = append(result, getTwoBusiestPerDC(replicas)...) } return result, nil diff --git a/tests/integration/get-cluster-heuristic-lag-multi-dc/create.sql b/tests/integration/get-cluster-heuristic-lag-multi-dc/create.sql new file mode 100644 index 000000000..358cc769b --- /dev/null +++ b/tests/integration/get-cluster-heuristic-lag-multi-dc/create.sql @@ -0,0 +1,124 @@ +-- topology: +-- +-- x x x x x +-- ^dc +-- ^ 1st tier server id +-- ^ 2nd tier server id +-- ^ 3rd tier server id + +-- 55555 +-- + 11000 (dc1) (lag=7) +-- + 11100 (lag=8) +-- + 11200 (lag=8) +-- + 11300 (lag=7) +-- + 21000 (dc2) (lag=0) <-- the same busyness as 22000. Both have 1 replica +-- + 21100 (lag=1) +-- + 22000 (dc2) (lag=0) +-- + 22100 (lag=10) +-- + 23000 (dc2) (lag=0) +-- + 23100 (lag=9) <-- this is the result +-- + 23200 (lag=8) +-- + 31000 (dc3) (lag=2) +-- + 32000 (dc3) (lag=2) +-- + 32100 (lag=5) +-- + 32110 (lag=5) +-- + 32200 (lag=4) +-- + 32210 (lag=4) +-- + 32220 (lag=4) +-- + 32230 (lag=7) +-- + 33000 (dc3) (lag=3) +-- + +-- drop the default configuration +DELETE FROM database_instance; + +-- create the topology as shown above +-- add servers +-- 55555 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',55555,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,55555,'00022293-0000-0000-0000-000000055555','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',22294,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,7,'[{"Hostname":"testhost","Port":11000},{"Hostname":"testhost","Port":21000},{"Hostname":"testhost","Port":22000},{"Hostname":"testhost","Port":23000},{"Hostname":"testhost","Port":31000},{"Hostname":"testhost","Port":32000},{"Hostname":"testhost","Port":33000}]','testhost:55555','','ny','us-region','','',0,0,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,11000,'00022293-0000-0000-0000-000000011000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,3,'[{"Hostname":"testhost","Port":11100},{"Hostname":"testhost","Port":11200},{"Hostname":"testhost","Port":11300}]','testhost:55555','','dc1','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000011100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',11000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc1','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11200 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11200,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000011200','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',11000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc1','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11300 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11300,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000011300','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',11000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc1','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 21000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',21000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000021000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,1,'[{"Hostname":"testhost","Port":21100}]','testhost:55555','','dc2','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 21100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',21100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000021100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',21000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 22000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',22000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000022000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,1,'[{"Hostname":"testhost","Port":22100}]','testhost:55555','','dc2','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 22100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',22100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000022100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',22000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 23000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',23000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000023000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,2,'[{"Hostname":"testhost","Port":23100},{"Hostname":"testhost","Port":23200}]','testhost:55555','','dc2','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 23100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',23100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000023100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',23000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 23200 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',23200,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000023200','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',23000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 31000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',31000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000031000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + + +-- 32000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,2,'[{"Hostname":"testhost","Port":32100},{"Hostname":"testhost","Port":32200}]','testhost:55555','','dc3','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000033100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,1,'[{"Hostname":"testhost","Port":32110}]','testhost:55555','','dc3','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32110 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32110,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032110','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32100,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32200 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32200,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032200','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,3,'[{"Hostname":"testhost","Port":32210},{"Hostname":"testhost","Port":32220},{"Hostname":"testhost","Port":32230}]','testhost:55555','','dc3','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32210 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32210,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032210','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32200,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32220 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32220,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032220','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32200,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32230 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32230,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032230','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32200,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 33000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',33000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000033000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- setup lag +UPDATE database_instance SET slave_lag_seconds=7 where port = 11000; +UPDATE database_instance SET slave_lag_seconds=8 where port = 11100; +UPDATE database_instance SET slave_lag_seconds=8 where port = 11200; +UPDATE database_instance SET slave_lag_seconds=7 where port = 11300; + +UPDATE database_instance SET slave_lag_seconds=0 where port = 21000; +UPDATE database_instance SET slave_lag_seconds=1 where port = 21100; +UPDATE database_instance SET slave_lag_seconds=0 where port = 22000; +UPDATE database_instance SET slave_lag_seconds=10 where port = 22100; +UPDATE database_instance SET slave_lag_seconds=0 where port = 23000; +UPDATE database_instance SET slave_lag_seconds=9 where port = 23100; +UPDATE database_instance SET slave_lag_seconds=8 where port = 23200; + +UPDATE database_instance SET slave_lag_seconds=2 where port = 31000; +UPDATE database_instance SET slave_lag_seconds=2 where port = 32000; +UPDATE database_instance SET slave_lag_seconds=5 where port = 32100; +UPDATE database_instance SET slave_lag_seconds=5 where port = 32110; +UPDATE database_instance SET slave_lag_seconds=4 where port = 32200; +UPDATE database_instance SET slave_lag_seconds=4 where port = 32210; +UPDATE database_instance SET slave_lag_seconds=4 where port = 32220; +UPDATE database_instance SET slave_lag_seconds=7 where port = 32230; +UPDATE database_instance SET slave_lag_seconds=3 where port = 33000; + diff --git a/tests/integration/get-cluster-heuristic-lag-multi-dc/expect_output b/tests/integration/get-cluster-heuristic-lag-multi-dc/expect_output new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/tests/integration/get-cluster-heuristic-lag-multi-dc/expect_output @@ -0,0 +1 @@ +9 diff --git a/tests/integration/get-cluster-heuristic-lag-multi-dc/extra_args b/tests/integration/get-cluster-heuristic-lag-multi-dc/extra_args new file mode 100644 index 000000000..88d893f3b --- /dev/null +++ b/tests/integration/get-cluster-heuristic-lag-multi-dc/extra_args @@ -0,0 +1 @@ +-c get-cluster-heuristic-lag -i testhost:55555 diff --git a/tests/integration/which-cluster-ocs-replicas/create.sql b/tests/integration/which-cluster-ocs-replicas/create.sql new file mode 100644 index 000000000..cc899d77f --- /dev/null +++ b/tests/integration/which-cluster-ocs-replicas/create.sql @@ -0,0 +1,124 @@ +-- topology: +-- +-- x x x x x +-- ^dc +-- ^ 1st tier server id +-- ^ 2nd tier server id +-- ^ 3rd tier server id + +-- 55555 +-- + 11000 (dc1) (lag=7) <-- +-- + 11100 (lag=8) <-- +-- + 11200 (lag=8) <-- +-- + 11300 (lag=7) +-- + 21000 (dc2) (lag=0) <-- +-- + 21100 (lag=1) <-- +-- + 22000 (dc2) (lag=0) +-- + 22100 (lag=10) +-- + 23000 (dc2) (lag=0) <-- +-- + 23100 (lag=9) <-- +-- + 23200 (lag=8) <-- +-- + 31000 (dc3) (lag=2) +-- + 32000 (dc3) (lag=2) <-- +-- + 32100 (lag=5) <-- +-- + 32110 (lag=5) <-- +-- + 32200 (lag=4) <-- +-- + 32210 (lag=4) +-- + 32220 (lag=4) +-- + 32230 (lag=7) <-- +-- + 33000 (dc3) (lag=3) <-- +-- + +-- drop the default configuration +DELETE FROM database_instance; + +-- create the topology as shown above +-- add servers +-- 55555 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',55555,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,55555,'00022293-0000-0000-0000-000000055555','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',22294,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,7,'[{"Hostname":"testhost","Port":11000},{"Hostname":"testhost","Port":21000},{"Hostname":"testhost","Port":22000},{"Hostname":"testhost","Port":23000},{"Hostname":"testhost","Port":31000},{"Hostname":"testhost","Port":32000},{"Hostname":"testhost","Port":33000}]','testhost:55555','','ny','us-region','','',0,0,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,11000,'00022293-0000-0000-0000-000000011000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,3,'[{"Hostname":"testhost","Port":11100},{"Hostname":"testhost","Port":11200},{"Hostname":"testhost","Port":11300}]','testhost:55555','','dc1','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000011100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',11000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc1','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11200 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11200,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000011200','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',11000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc1','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 11300 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',11300,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000011300','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',11000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc1','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 21000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',21000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000021000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,1,'[{"Hostname":"testhost","Port":21100}]','testhost:55555','','dc2','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 21100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',21100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000021100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',21000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 22000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',22000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000022000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,1,'[{"Hostname":"testhost","Port":22100}]','testhost:55555','','dc2','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 22100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',22100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000022100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',22000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 23000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',23000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000023000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,2,'[{"Hostname":"testhost","Port":23100},{"Hostname":"testhost","Port":23200}]','testhost:55555','','dc2','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 23100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',23100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000023100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',23000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 23200 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',23200,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000023200','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',23000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc2','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 31000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',31000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000031000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + + +-- 32000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,2,'[{"Hostname":"testhost","Port":32100},{"Hostname":"testhost","Port":32200}]','testhost:55555','','dc3','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32100 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32100,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000033100','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,1,'[{"Hostname":"testhost","Port":32110}]','testhost:55555','','dc3','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32110 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32110,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032110','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32100,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32200 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32200,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032200','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32000,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,3,'[{"Hostname":"testhost","Port":32210},{"Hostname":"testhost","Port":32220},{"Hostname":"testhost","Port":32230}]','testhost:55555','','dc3','us-region','','',0,2,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32210 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32210,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032210','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32200,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32220 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32220,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032220','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32200,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 32230 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',32230,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000032230','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',32200,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,3,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- 33000 +INSERT INTO database_instance (hostname, port, last_checked, last_attempted_check, last_seen, uptime, server_id, server_uuid, version, binlog_server, read_only, binlog_format, log_bin, log_slave_updates, binary_log_file, binary_log_pos, master_host, master_port, slave_sql_running, slave_io_running, has_replication_filters, oracle_gtid, master_uuid, ancestry_uuid, executed_gtid_set, gtid_purged, gtid_errant, supports_oracle_gtid, mariadb_gtid, pseudo_gtid, master_log_file, read_master_log_pos, relay_master_log_file, exec_master_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, seconds_behind_master, slave_lag_seconds, sql_delay, allow_tls, num_slave_hosts, slave_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, instance_alias, semi_sync_enforced, replication_depth, is_co_master, replication_credentials_available, has_replication_credentials, version_comment, major_version, last_check_partial_success, binlog_row_image, last_discovery_latency, semi_sync_master_enabled, semi_sync_replica_enabled, gtid_mode, replication_group_members) VALUES ('testhost',33000,'2017-02-02 08:29:57','2017-02-02 08:29:57','2017-02-02 08:29:57',670442,102,'00022293-0000-0000-0000-000000033000','5.6.28-log',0,0,'STATEMENT',1,1,'mysql-bin.000129',136688950,'testhost',55555,1,1,0,0,'','','','','',0,0,1,'mysql-bin.000132',15931747,'mysql-bin.000132',15931747,'mysql-relay.000002',15868528,'\"\"','\"\"',0,0,0,0,0,'[]','testhost:55555','','dc3','us-region','','',0,1,0,0,1,'MySQL Community Server (GPL)','5.6',0,'full',0,0,0,'OFF', '[]'); + +-- setup lag +UPDATE database_instance SET slave_lag_seconds=7 where port = 11000; +UPDATE database_instance SET slave_lag_seconds=8 where port = 11100; +UPDATE database_instance SET slave_lag_seconds=8 where port = 11200; +UPDATE database_instance SET slave_lag_seconds=7 where port = 11300; + +UPDATE database_instance SET slave_lag_seconds=0 where port = 21000; +UPDATE database_instance SET slave_lag_seconds=1 where port = 21100; +UPDATE database_instance SET slave_lag_seconds=0 where port = 22000; +UPDATE database_instance SET slave_lag_seconds=10 where port = 22100; +UPDATE database_instance SET slave_lag_seconds=0 where port = 23000; +UPDATE database_instance SET slave_lag_seconds=9 where port = 23100; +UPDATE database_instance SET slave_lag_seconds=8 where port = 23200; + +UPDATE database_instance SET slave_lag_seconds=2 where port = 31000; +UPDATE database_instance SET slave_lag_seconds=2 where port = 32000; +UPDATE database_instance SET slave_lag_seconds=5 where port = 32100; +UPDATE database_instance SET slave_lag_seconds=5 where port = 32110; +UPDATE database_instance SET slave_lag_seconds=4 where port = 32200; +UPDATE database_instance SET slave_lag_seconds=4 where port = 32210; +UPDATE database_instance SET slave_lag_seconds=4 where port = 32220; +UPDATE database_instance SET slave_lag_seconds=7 where port = 32230; +UPDATE database_instance SET slave_lag_seconds=3 where port = 33000; + diff --git a/tests/integration/which-cluster-ocs-replicas/expect_output b/tests/integration/which-cluster-ocs-replicas/expect_output new file mode 100644 index 000000000..daab0198a --- /dev/null +++ b/tests/integration/which-cluster-ocs-replicas/expect_output @@ -0,0 +1,14 @@ +testhost:11000 +testhost:11100 +testhost:11200 +testhost:21000 +testhost:21100 +testhost:23000 +testhost:23100 +testhost:23200 +testhost:32000 +testhost:32100 +testhost:32110 +testhost:32200 +testhost:32230 +testhost:33000 diff --git a/tests/integration/which-cluster-ocs-replicas/extra_args b/tests/integration/which-cluster-ocs-replicas/extra_args new file mode 100644 index 000000000..7756db944 --- /dev/null +++ b/tests/integration/which-cluster-ocs-replicas/extra_args @@ -0,0 +1 @@ +-c which-cluster-osc-replicas -i testhost:55555 | sort