From 61d2edf5fa6b336b40094349aab3bade2c370622 Mon Sep 17 00:00:00 2001 From: Lonng Date: Thu, 6 Feb 2020 12:21:17 +0800 Subject: [PATCH 01/14] infoschema: move column `value` of metrics to last Signed-off-by: Lonng --- executor/metric_reader.go | 10 +++++----- infoschema/metric_schema.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/executor/metric_reader.go b/executor/metric_reader.go index cea4206048e24..7545bade99250 100644 --- a/executor/metric_reader.go +++ b/executor/metric_reader.go @@ -150,11 +150,6 @@ func (e *MetricRetriever) genRecord(metric pmodel.Metric, pair pmodel.SamplePair mysql.TypeDatetime, types.MaxFsp, ))) - if math.IsNaN(float64(pair.Value)) { - record = append(record, types.NewDatum(nil)) - } else { - record = append(record, types.NewFloat64Datum(float64(pair.Value))) - } for _, label := range e.tblDef.Labels { v := "" if metric != nil { @@ -168,6 +163,11 @@ func (e *MetricRetriever) genRecord(metric pmodel.Metric, pair pmodel.SamplePair if e.tblDef.Quantile > 0 { record = append(record, types.NewFloat64Datum(quantile)) } + if math.IsNaN(float64(pair.Value)) { + record = append(record, types.NewDatum(nil)) + } else { + record = append(record, types.NewFloat64Datum(float64(pair.Value))) + } return record } diff --git a/infoschema/metric_schema.go b/infoschema/metric_schema.go index f879eec2fcfeb..3411cc3373a71 100644 --- a/infoschema/metric_schema.go +++ b/infoschema/metric_schema.go @@ -85,7 +85,6 @@ func GetMetricTableDef(lowerTableName string) (*MetricTableDef, error) { func (def *MetricTableDef) genColumnInfos() []columnInfo { cols := []columnInfo{ {"time", mysql.TypeDatetime, 19, 0, "CURRENT_TIMESTAMP", nil}, - {"value", mysql.TypeDouble, 22, 0, nil, nil}, } for _, label := range def.Labels { cols = append(cols, columnInfo{label, mysql.TypeVarchar, 512, 0, nil, nil}) @@ -94,6 +93,7 @@ func (def *MetricTableDef) genColumnInfos() []columnInfo { defaultValue := strconv.FormatFloat(def.Quantile, 'f', -1, 64) cols = append(cols, columnInfo{"quantile", mysql.TypeDouble, 22, 0, defaultValue, nil}) } + cols = append(cols, columnInfo{"value", mysql.TypeDouble, 22, 0, nil, nil}) return cols } From eacc69eb59f0286c38c7bc1611db2b45f4a35500 Mon Sep 17 00:00:00 2001 From: Lonng Date: Thu, 6 Feb 2020 14:44:13 +0800 Subject: [PATCH 02/14] executor: display all nodes system info Signed-off-by: Lonng --- executor/cluster_reader.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/executor/cluster_reader.go b/executor/cluster_reader.go index 247478e38dc89..a81b085cb38a1 100644 --- a/executor/cluster_reader.go +++ b/executor/cluster_reader.go @@ -244,7 +244,6 @@ func (e *clusterServerInfoRetriever) retrieve(ctx context.Context, sctx sessionc } wg := sync.WaitGroup{} ch := make(chan result, len(serversInfo)) - ipMap := make(map[string]struct{}, len(serversInfo)) infoTp := e.serverInfoType finalRows := make([][]types.Datum, 0, len(serversInfo)*10) for i, srv := range serversInfo { @@ -252,14 +251,6 @@ func (e *clusterServerInfoRetriever) retrieve(ctx context.Context, sctx sessionc if srv.ServerType == "tidb" { address = srv.StatusAddr } - ip := address - if idx := strings.Index(address, ":"); idx != -1 { - ip = address[:idx] - } - if _, ok := ipMap[ip]; ok { - continue - } - ipMap[ip] = struct{}{} wg.Add(1) go func(index int, address, serverTP string) { util.WithRecovery(func() { From 7807d667f92af3ce5d80ad4c1e05f5409cc7444e Mon Sep 17 00:00:00 2001 From: Lonng Date: Fri, 7 Feb 2020 11:37:57 +0800 Subject: [PATCH 03/14] diagnostics: implement disk/cpu/memory/swap rules Signed-off-by: Lonng --- executor/cluster_reader.go | 6 +- executor/diagnostics.go | 164 +++++++++++--- infoschema/cluster.go | 2 +- infoschema/tables.go | 20 +- planner/core/memtable_predicate_extractor.go | 32 +-- .../core/memtable_predicate_extractor_test.go | 214 +++++++++--------- 6 files changed, 272 insertions(+), 166 deletions(-) diff --git a/executor/cluster_reader.go b/executor/cluster_reader.go index a81b085cb38a1..860cf26339653 100644 --- a/executor/cluster_reader.go +++ b/executor/cluster_reader.go @@ -118,7 +118,7 @@ func (e *clusterConfigRetriever) retrieve(_ context.Context, sctx sessionctx.Con if err != nil { return nil, err } - serversInfo = filterClusterServerInfo(serversInfo, e.extractor.NodeTypes, e.extractor.Addresses) + serversInfo = filterClusterServerInfo(serversInfo, e.extractor.NodeTypes, e.extractor.Instances) var finalRows [][]types.Datum wg := sync.WaitGroup{} @@ -235,7 +235,7 @@ func (e *clusterServerInfoRetriever) retrieve(ctx context.Context, sctx sessionc if err != nil { return nil, err } - serversInfo = filterClusterServerInfo(serversInfo, e.extractor.NodeTypes, e.extractor.Addresses) + serversInfo = filterClusterServerInfo(serversInfo, e.extractor.NodeTypes, e.extractor.Instances) type result struct { idx int @@ -432,7 +432,7 @@ func (e *clusterLogRetriever) startRetrieving(ctx context.Context, sctx sessionc return nil, err } - addresses := e.extractor.Addresses + addresses := e.extractor.Instances nodeTypes := e.extractor.NodeTypes serversInfo = filterClusterServerInfo(serversInfo, nodeTypes, addresses) diff --git a/executor/diagnostics.go b/executor/diagnostics.go index 80239ec492756..86e3d17bef144 100644 --- a/executor/diagnostics.go +++ b/executor/diagnostics.go @@ -24,6 +24,7 @@ import ( "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/variable" "github.com/pingcap/tidb/types" + "github.com/pingcap/tidb/util/chunk" "github.com/pingcap/tidb/util/set" "github.com/pingcap/tidb/util/sqlexec" ) @@ -31,24 +32,33 @@ import ( type ( // inspectionResult represents a abnormal diagnosis result inspectionResult struct { + typ string + instance string // represents the diagnostics item, e.g: `ddl.lease` `raftstore.cpuusage` item string // diagnosis result value base on current cluster status - actual string - expected string - severity string - suggestion string + actual string + expected string + severity string + detail string } + inspectionFilter struct{ set.StringSet } + inspectionRule interface { name() string - inspect(ctx context.Context, sctx sessionctx.Context, filter set.StringSet) []inspectionResult + inspect(ctx context.Context, sctx sessionctx.Context, filter inspectionFilter) []inspectionResult } ) +func (f inspectionFilter) enable(name string) bool { + return len(f.StringSet) == 0 || f.Exist(name) +} + var inspectionRules = []inspectionRule{ &configInspection{}, &versionInspection{}, + ¤tLoadInspection{}, } type inspectionRetriever struct { @@ -85,12 +95,12 @@ func (e *inspectionRetriever) retrieve(ctx context.Context, sctx sessionctx.Cont } }) - rules := e.extractor.Rules - items := e.extractor.Items + rules := inspectionFilter{e.extractor.Rules} + items := inspectionFilter{e.extractor.Items} var finalRows [][]types.Datum for _, r := range inspectionRules { name := r.name() - if len(rules) > 0 && !rules.Exist(name) { + if !rules.enable(name) { continue } results := r.inspect(ctx, sctx, items) @@ -106,12 +116,14 @@ func (e *inspectionRetriever) retrieve(ctx context.Context, sctx sessionctx.Cont }) for _, result := range results { finalRows = append(finalRows, types.MakeDatums( + result.typ, + result.instance, name, result.item, result.actual, result.expected, result.severity, - result.suggestion, + result.detail, )) } } @@ -124,7 +136,7 @@ func (configInspection) name() string { return "config" } -func (configInspection) inspect(_ context.Context, sctx sessionctx.Context, filter set.StringSet) []inspectionResult { +func (configInspection) inspect(_ context.Context, sctx sessionctx.Context, filter inspectionFilter) []inspectionResult { // check the configuration consistent sql := "select type, `key`, count(distinct value) as c from inspection_schema.cluster_config group by type, `key` having c > 1" rows, _, err := sctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(sql) @@ -134,17 +146,18 @@ func (configInspection) inspect(_ context.Context, sctx sessionctx.Context, filt var results []inspectionResult for _, row := range rows { - if len(filter) > 0 && !filter.Exist(row.GetString(1)) { - continue + if filter.enable(row.GetString(1)) { + results = append(results, inspectionResult{ + typ: row.GetString(0), + instance: "", + item: row.GetString(1), // key + actual: "inconsistent", + expected: "consistent", + severity: "warning", + detail: fmt.Sprintf("select * from information_schema.cluster_config where type='%s' and `key`='%s'", + row.GetString(0), row.GetString(1)), + }) } - results = append(results, inspectionResult{ - item: row.GetString(1), // key - actual: "inconsistent", - expected: "consistent", - severity: "warning", - suggestion: fmt.Sprintf("select * from information_schema.cluster_config where type='%s' and `key`='%s'", - row.GetString(0), row.GetString(1)), - }) } return results } @@ -155,7 +168,7 @@ func (versionInspection) name() string { return "version" } -func (versionInspection) inspect(_ context.Context, sctx sessionctx.Context, filter set.StringSet) []inspectionResult { +func (versionInspection) inspect(_ context.Context, sctx sessionctx.Context, filter inspectionFilter) []inspectionResult { // check the configuration consistent sql := "select type, count(distinct git_hash) as c from inspection_schema.cluster_info group by type having c > 1;" rows, _, err := sctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(sql) @@ -163,18 +176,109 @@ func (versionInspection) inspect(_ context.Context, sctx sessionctx.Context, fil sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("check version consistency failed: %v", err)) } + const name = "git_hash" var results []inspectionResult for _, row := range rows { - if len(filter) > 0 && !filter.Exist(row.GetString(0)) { - continue + if filter.enable(name) { + results = append(results, inspectionResult{ + typ: row.GetString(0), + instance: "", + item: name, + actual: "inconsistent", + expected: "consistent", + severity: "critical", + detail: fmt.Sprintf("select * from information_schema.cluster_info where type='%s'", row.GetString(0)), + }) + } + } + return results +} + +type currentLoadInspection struct{} + +func (currentLoadInspection) name() string { + return "current-load" +} + +func (currentLoadInspection) inspect(_ context.Context, sctx sessionctx.Context, filter inspectionFilter) []inspectionResult { + var commonResult = func(item string, expected string, row chunk.Row) inspectionResult { + return inspectionResult{ + typ: row.GetString(0), + instance: row.GetString(1), + item: item, + actual: row.GetString(2), + expected: expected, + severity: "warning", + } + } + var diskResult = func(item string, expected string, row chunk.Row) inspectionResult { + return inspectionResult{ + typ: row.GetString(0), + instance: row.GetString(1), + item: item, + actual: row.GetString(3), + expected: expected, + severity: "warning", + detail: fmt.Sprintf("select * from information_schema.cluster_hardware where type='%s' and instance='%s' and device_type='disk' and device_name='%s'", + row.GetString(0), row.GetString(1), row.GetString(2)), + } + } + var rules = []struct { + item string + sql string + expected string + result func(string, string, chunk.Row) inspectionResult + }{ + { + "virtual-memory-usage", + "select type, instance, value from inspection_schema.cluster_load where device_type='memory' and device_name='virtual' and load_name='used-percent' and load_value > 0.7", + "<0.7", + commonResult, + }, + { + "swap-memory-usage", + "select type, instance, value from inspection_schema.cluster_load where device_type='memory' and device_name='swap' and load_name='used-percent' and load_value > 0", + "0", + commonResult, + }, + { + "disk-usage", + "select type, instance, device_name, value from inspection_schema.cluster_hardware where device_type='disk' and name='used-percent' and value > 70", + "<70", + diskResult, + }, + { + "cpu-load1", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load1' and load_value>0.7;", + "<0.7", + commonResult, + }, + { + "cpu-load5", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load5' and load_value>0.7;", + "<0.7", + commonResult, + }, + { + "cpu-load15", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load15' and load_value>0.7;", + "<0.7", + commonResult, + }, + } + + var results []inspectionResult + for _, rule := range rules { + if filter.enable(rule.item) { + rows, _, err := sctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(rule.sql) + if err != nil { + sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("check load %s failed: %v", rule.item, err)) + continue + } + for _, row := range rows { + results = append(results, rule.result(rule.item, rule.expected, row)) + } } - results = append(results, inspectionResult{ - item: row.GetString(0), // type - actual: "inconsistent", - expected: "consistent", - severity: "critical", - suggestion: fmt.Sprintf("select * from information_schema.cluster_info where type='%s'", row.GetString(0)), - }) } return results } diff --git a/infoschema/cluster.go b/infoschema/cluster.go index 6105d5f9fd23b..85b9e2c69e8b2 100644 --- a/infoschema/cluster.go +++ b/infoschema/cluster.go @@ -40,7 +40,7 @@ var memTableToClusterTables = map[string]string{ } func init() { - var addrCol = columnInfo{"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil} + var addrCol = columnInfo{"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil} for memTableName, clusterMemTableName := range memTableToClusterTables { memTableCols := tableNameToColumns[memTableName] if len(memTableCols) == 0 { diff --git a/infoschema/tables.go b/infoschema/tables.go index 18e9e7c8bdfcc..cd1b65cc832f2 100755 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -736,7 +736,7 @@ var tableTiDBServersInfoCols = []columnInfo{ var tableClusterConfigCols = []columnInfo{ {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"KEY", mysql.TypeVarchar, 256, 0, nil, nil}, {"VALUE", mysql.TypeVarchar, 128, 0, nil, nil}, } @@ -744,23 +744,23 @@ var tableClusterConfigCols = []columnInfo{ var tableClusterLogCols = []columnInfo{ {"TIME", mysql.TypeVarchar, 32, 0, nil, nil}, {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"LEVEL", mysql.TypeVarchar, 8, 0, nil, nil}, {"MESSAGE", mysql.TypeVarString, 1024, 0, nil, nil}, } var tableClusterLoadCols = []columnInfo{ {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"DEVICE_TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, {"DEVICE_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, - {"LOAD_NAME", mysql.TypeVarchar, 256, 0, nil, nil}, - {"LOAD_VALUE", mysql.TypeVarchar, 128, 0, nil, nil}, + {"NAME", mysql.TypeVarchar, 256, 0, nil, nil}, + {"VALUE", mysql.TypeVarchar, 128, 0, nil, nil}, } var tableClusterHardwareCols = []columnInfo{ {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"DEVICE_TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, {"DEVICE_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, {"NAME", mysql.TypeVarchar, 256, 0, nil, nil}, @@ -769,7 +769,7 @@ var tableClusterHardwareCols = []columnInfo{ var tableClusterSystemInfoCols = []columnInfo{ {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"SYSTEM_TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, {"SYSTEM_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, {"NAME", mysql.TypeVarchar, 256, 0, nil, nil}, @@ -1102,7 +1102,7 @@ var filesCols = []columnInfo{ var tableClusterInfoCols = []columnInfo{ {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"STATUS_ADDRESS", mysql.TypeVarchar, 64, 0, nil, nil}, {"VERSION", mysql.TypeVarchar, 64, 0, nil, nil}, {"GIT_HASH", mysql.TypeVarchar, 64, 0, nil, nil}, @@ -1118,12 +1118,14 @@ var tableTableTiFlashReplicaCols = []columnInfo{ } var tableInspectionResultCols = []columnInfo{ + {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"RULE", mysql.TypeVarchar, 64, 0, nil, nil}, {"ITEM", mysql.TypeVarchar, 64, 0, nil, nil}, {"VALUE", mysql.TypeVarchar, 64, 0, nil, nil}, {"REFERENCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"SEVERITY", mysql.TypeVarchar, 64, 0, nil, nil}, - {"SUGGESTION", mysql.TypeVarchar, 256, 0, nil, nil}, + {"DETAILS", mysql.TypeVarchar, 256, 0, nil, nil}, } var tableMetricSummaryCols = []columnInfo{ diff --git a/planner/core/memtable_predicate_extractor.go b/planner/core/memtable_predicate_extractor.go index fba8d99d5332e..01f0b3f07de06 100644 --- a/planner/core/memtable_predicate_extractor.go +++ b/planner/core/memtable_predicate_extractor.go @@ -35,13 +35,13 @@ import ( // and push the predicates down to the data retrieving on reading memory table stage. // // e.g: -// SELECT * FROM cluster_config WHERE type='tikv' AND address='192.168.1.9:2379' +// SELECT * FROM cluster_config WHERE type='tikv' AND instance='192.168.1.9:2379' // We must request all components in the cluster via HTTP API for retrieving -// configurations and filter them by `type/address` columns. +// configurations and filter them by `type/instance` columns. // // The purpose of defining a `MemTablePredicateExtractor` is to optimize this // 1. Define a `ClusterConfigTablePredicateExtractor` -// 2. Extract the `type/address` columns on the logic optimizing stage and save them via fields. +// 2. Extract the `type/instance` columns on the logic optimizing stage and save them via fields. // 3. Passing the extractor to the `ClusterReaderExecExec` executor // 4. Executor sends requests to the target components instead of all of the components type MemTablePredicateExtractor interface { @@ -381,11 +381,11 @@ type ClusterTableExtractor struct { // 2. SELECT * FROM cluster_config WHERE type in ('tikv', 'tidb') NodeTypes set.StringSet - // Addresses represents all components addresses we should send request to. + // Instances represents all components instances we should send request to. // e.g: - // 1. SELECT * FROM cluster_config WHERE address='192.168.1.7:2379' + // 1. SELECT * FROM cluster_config WHERE instance='192.168.1.7:2379' // 2. SELECT * FROM cluster_config WHERE type in ('192.168.1.7:2379', '192.168.1.9:2379') - Addresses set.StringSet + Instances set.StringSet } // Extract implements the MemTablePredicateExtractor Extract interface @@ -395,10 +395,10 @@ func (e *ClusterTableExtractor) Extract(_ sessionctx.Context, predicates []expression.Expression, ) []expression.Expression { remained, typeSkipRequest, nodeTypes := e.extractCol(schema, names, predicates, "type", true) - remained, addrSkipRequest, addresses := e.extractCol(schema, names, remained, "address", false) + remained, addrSkipRequest, instances := e.extractCol(schema, names, remained, "instance", false) e.SkipRequest = typeSkipRequest || addrSkipRequest e.NodeTypes = nodeTypes - e.Addresses = addresses + e.Instances = instances return remained } @@ -415,11 +415,11 @@ type ClusterLogTableExtractor struct { // 2. SELECT * FROM cluster_log WHERE type in ('tikv', 'tidb') NodeTypes set.StringSet - // Addresses represents all components addresses we should send request to. + // Instances represents all components instances we should send request to. // e.g: - // 1. SELECT * FROM cluster_log WHERE address='192.168.1.7:2379' - // 2. SELECT * FROM cluster_log WHERE address in ('192.168.1.7:2379', '192.168.1.9:2379') - Addresses set.StringSet + // 1. SELECT * FROM cluster_log WHERE instance='192.168.1.7:2379' + // 2. SELECT * FROM cluster_log WHERE instance in ('192.168.1.7:2379', '192.168.1.9:2379') + Instances set.StringSet // StartTime represents the beginning time of log message // e.g: SELECT * FROM cluster_log WHERE time>'2019-10-10 10:10:10.999' @@ -442,13 +442,13 @@ func (e *ClusterLogTableExtractor) Extract( names []*types.FieldName, predicates []expression.Expression, ) []expression.Expression { - // Extract the `type/address` columns + // Extract the `type/instance` columns remained, typeSkipRequest, nodeTypes := e.extractCol(schema, names, predicates, "type", true) - remained, addrSkipRequest, addresses := e.extractCol(schema, names, remained, "address", false) + remained, addrSkipRequest, instances := e.extractCol(schema, names, remained, "instance", false) remained, levlSkipRequest, logLevels := e.extractCol(schema, names, remained, "level", true) e.SkipRequest = typeSkipRequest || addrSkipRequest || levlSkipRequest e.NodeTypes = nodeTypes - e.Addresses = addresses + e.Instances = instances e.LogLevels = logLevels if e.SkipRequest { return nil @@ -600,7 +600,7 @@ func (e *InspectionResultTableExtractor) Extract( names []*types.FieldName, predicates []expression.Expression, ) (remained []expression.Expression) { - // Extract the `type/address` columns + // Extract the `type/instance` columns remained, ruleSkip, rules := e.extractCol(schema, names, predicates, "rule", true) remained, itemSkip, items := e.extractCol(schema, names, remained, "item", true) e.SkipInspection = ruleSkip || itemSkip diff --git a/planner/core/memtable_predicate_extractor_test.go b/planner/core/memtable_predicate_extractor_test.go index fc885cb5f48b2..8d7b6d4e03a13 100644 --- a/planner/core/memtable_predicate_extractor_test.go +++ b/planner/core/memtable_predicate_extractor_test.go @@ -86,150 +86,150 @@ func (s *extractorSuite) TestClusterConfigTableExtractor(c *C) { var cases = []struct { sql string nodeTypes set.StringSet - addresses set.StringSet + instances set.StringSet skipRequest bool }{ { sql: "select * from information_schema.cluster_config", nodeTypes: nil, - addresses: nil, + instances: nil, }, { sql: "select * from information_schema.cluster_config where type='tikv'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_config where 'tikv'=type", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_config where 'TiKV'=type", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_config where 'tikv'=type", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_config where 'TiKV'=type or type='tidb'", nodeTypes: set.NewStringSet("tikv", "tidb"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_config where 'TiKV'=type or type='tidb' or type='pd'", nodeTypes: set.NewStringSet("tikv", "tidb", "pd"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { - sql: "select * from information_schema.cluster_config where (type='tidb' or type='pd') and (address='123.1.1.2:1234' or address='123.1.1.4:1234')", + sql: "select * from information_schema.cluster_config where (type='tidb' or type='pd') and (instance='123.1.1.2:1234' or instance='123.1.1.4:1234')", nodeTypes: set.NewStringSet("tidb", "pd"), - addresses: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), }, { sql: "select * from information_schema.cluster_config where type in ('tikv', 'pd')", nodeTypes: set.NewStringSet("tikv", "pd"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { - sql: "select * from information_schema.cluster_config where type in ('tikv', 'pd') and address='123.1.1.2:1234'", + sql: "select * from information_schema.cluster_config where type in ('tikv', 'pd') and instance='123.1.1.2:1234'", nodeTypes: set.NewStringSet("tikv", "pd"), - addresses: set.NewStringSet("123.1.1.2:1234"), + instances: set.NewStringSet("123.1.1.2:1234"), }, { - sql: "select * from information_schema.cluster_config where type in ('tikv', 'pd') and address in ('123.1.1.2:1234', '123.1.1.4:1234')", + sql: "select * from information_schema.cluster_config where type in ('tikv', 'pd') and instance in ('123.1.1.2:1234', '123.1.1.4:1234')", nodeTypes: set.NewStringSet("tikv", "pd"), - addresses: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_config where type='tikv' and address in ('123.1.1.2:1234', '123.1.1.4:1234')", + sql: "select * from information_schema.cluster_config where type='tikv' and instance in ('123.1.1.2:1234', '123.1.1.4:1234')", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_config where type='tikv' and address='123.1.1.4:1234'", + sql: "select * from information_schema.cluster_config where type='tikv' and instance='123.1.1.4:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_config where type='tikv' and address='123.1.1.4:1234'", + sql: "select * from information_schema.cluster_config where type='tikv' and instance='123.1.1.4:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_config where type='tikv' and address='cNs2dm.tikv.pingcap.com:1234'", + sql: "select * from information_schema.cluster_config where type='tikv' and instance='cNs2dm.tikv.pingcap.com:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), + instances: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), }, { - sql: "select * from information_schema.cluster_config where type='TIKV' and address='cNs2dm.tikv.pingcap.com:1234'", + sql: "select * from information_schema.cluster_config where type='TIKV' and instance='cNs2dm.tikv.pingcap.com:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), + instances: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), }, { sql: "select * from information_schema.cluster_config where type='tikv' and type='pd'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { sql: "select * from information_schema.cluster_config where type='tikv' and type in ('pd', 'tikv')", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_config where type='tikv' and type in ('pd', 'tidb')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { sql: "select * from information_schema.cluster_config where type in ('tikv', 'tidb') and type in ('pd', 'tidb')", nodeTypes: set.NewStringSet("tidb"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { - sql: "select * from information_schema.cluster_config where address='123.1.1.4:1234' and address='123.1.1.5:1234'", + sql: "select * from information_schema.cluster_config where instance='123.1.1.4:1234' and instance='123.1.1.5:1234'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { - sql: "select * from information_schema.cluster_config where address='123.1.1.4:1234' and address in ('123.1.1.5:1234', '123.1.1.4:1234')", + sql: "select * from information_schema.cluster_config where instance='123.1.1.4:1234' and instance in ('123.1.1.5:1234', '123.1.1.4:1234')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet("123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_config where address='123.1.1.4:1234' and address in ('123.1.1.5:1234', '123.1.1.6:1234')", + sql: "select * from information_schema.cluster_config where instance='123.1.1.4:1234' and instance in ('123.1.1.5:1234', '123.1.1.6:1234')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { - sql: "select * from information_schema.cluster_config where address in ('123.1.1.5:1234', '123.1.1.4:1234') and address in ('123.1.1.5:1234', '123.1.1.6:1234')", + sql: "select * from information_schema.cluster_config where instance in ('123.1.1.5:1234', '123.1.1.4:1234') and instance in ('123.1.1.5:1234', '123.1.1.6:1234')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet("123.1.1.5:1234"), + instances: set.NewStringSet("123.1.1.5:1234"), }, { sql: `select * from information_schema.cluster_config - where address in ('123.1.1.5:1234', '123.1.1.4:1234') - and address in ('123.1.1.5:1234', '123.1.1.6:1234') + where instance in ('123.1.1.5:1234', '123.1.1.4:1234') + and instance in ('123.1.1.5:1234', '123.1.1.6:1234') and type in ('tikv', 'tidb') and type in ('pd', 'tidb')`, nodeTypes: set.NewStringSet("tidb"), - addresses: set.NewStringSet("123.1.1.5:1234"), + instances: set.NewStringSet("123.1.1.5:1234"), }, { sql: `select * from information_schema.cluster_config - where address in ('123.1.1.5:1234', '123.1.1.4:1234') - and address in ('123.1.1.5:1234', '123.1.1.6:1234') - and address in ('123.1.1.6:1234', '123.1.1.7:1234') - and address in ('123.1.1.7:1234', '123.1.1.8:1234')`, + where instance in ('123.1.1.5:1234', '123.1.1.4:1234') + and instance in ('123.1.1.5:1234', '123.1.1.6:1234') + and instance in ('123.1.1.6:1234', '123.1.1.7:1234') + and instance in ('123.1.1.7:1234', '123.1.1.8:1234')`, nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, } @@ -239,7 +239,7 @@ func (s *extractorSuite) TestClusterConfigTableExtractor(c *C) { clusterConfigExtractor := logicalMemTable.Extractor.(*plannercore.ClusterTableExtractor) c.Assert(clusterConfigExtractor.NodeTypes, DeepEquals, ca.nodeTypes, Commentf("SQL: %v", ca.sql)) - c.Assert(clusterConfigExtractor.Addresses, DeepEquals, ca.addresses, Commentf("SQL: %v", ca.sql)) + c.Assert(clusterConfigExtractor.Instances, DeepEquals, ca.instances, Commentf("SQL: %v", ca.sql)) c.Assert(clusterConfigExtractor.SkipRequest, DeepEquals, ca.skipRequest, Commentf("SQL: %v", ca.sql)) } } @@ -258,7 +258,7 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { var cases = []struct { sql string nodeTypes set.StringSet - addresses set.StringSet + instances set.StringSet skipRequest bool startTime, endTime int64 patterns []string @@ -267,173 +267,173 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { { sql: "select * from information_schema.cluster_log", nodeTypes: nil, - addresses: nil, + instances: nil, }, { sql: "select * from information_schema.cluster_log where type='tikv'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_log where 'tikv'=type", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_log where 'TiKV'=type", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_log where 'TiKV'=type or type='tidb'", nodeTypes: set.NewStringSet("tikv", "tidb"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_log where 'TiKV'=type or type='tidb' or type='pd'", nodeTypes: set.NewStringSet("tikv", "tidb", "pd"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { - sql: "select * from information_schema.cluster_log where (type='tidb' or type='pd') and (address='123.1.1.2:1234' or address='123.1.1.4:1234')", + sql: "select * from information_schema.cluster_log where (type='tidb' or type='pd') and (instance='123.1.1.2:1234' or instance='123.1.1.4:1234')", nodeTypes: set.NewStringSet("tidb", "pd"), - addresses: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), }, { sql: "select * from information_schema.cluster_log where type in ('tikv', 'pd')", nodeTypes: set.NewStringSet("tikv", "pd"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { - sql: "select * from information_schema.cluster_log where type in ('tikv', 'pd') and address='123.1.1.2:1234'", + sql: "select * from information_schema.cluster_log where type in ('tikv', 'pd') and instance='123.1.1.2:1234'", nodeTypes: set.NewStringSet("tikv", "pd"), - addresses: set.NewStringSet("123.1.1.2:1234"), + instances: set.NewStringSet("123.1.1.2:1234"), }, { - sql: "select * from information_schema.cluster_log where type in ('tikv', 'pd') and address in ('123.1.1.2:1234', '123.1.1.4:1234')", + sql: "select * from information_schema.cluster_log where type in ('tikv', 'pd') and instance in ('123.1.1.2:1234', '123.1.1.4:1234')", nodeTypes: set.NewStringSet("tikv", "pd"), - addresses: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_log where type='tikv' and address in ('123.1.1.2:1234', '123.1.1.4:1234')", + sql: "select * from information_schema.cluster_log where type='tikv' and instance in ('123.1.1.2:1234', '123.1.1.4:1234')", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.2:1234", "123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_log where type='tikv' and address='123.1.1.4:1234'", + sql: "select * from information_schema.cluster_log where type='tikv' and instance='123.1.1.4:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_log where type='tikv' and address='123.1.1.4:1234'", + sql: "select * from information_schema.cluster_log where type='tikv' and instance='123.1.1.4:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_log where type='tikv' and address='cNs2dm.tikv.pingcap.com:1234'", + sql: "select * from information_schema.cluster_log where type='tikv' and instance='cNs2dm.tikv.pingcap.com:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), + instances: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), }, { - sql: "select * from information_schema.cluster_log where type='TIKV' and address='cNs2dm.tikv.pingcap.com:1234'", + sql: "select * from information_schema.cluster_log where type='TIKV' and instance='cNs2dm.tikv.pingcap.com:1234'", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), + instances: set.NewStringSet("cNs2dm.tikv.pingcap.com:1234"), }, { sql: "select * from information_schema.cluster_log where type='tikv' and type='pd'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { sql: "select * from information_schema.cluster_log where type='tikv' and type in ('pd', 'tikv')", nodeTypes: set.NewStringSet("tikv"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { sql: "select * from information_schema.cluster_log where type='tikv' and type in ('pd', 'tidb')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { sql: "select * from information_schema.cluster_log where type in ('tikv', 'tidb') and type in ('pd', 'tidb')", nodeTypes: set.NewStringSet("tidb"), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), }, { - sql: "select * from information_schema.cluster_log where address='123.1.1.4:1234' and address='123.1.1.5:1234'", + sql: "select * from information_schema.cluster_log where instance='123.1.1.4:1234' and instance='123.1.1.5:1234'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { - sql: "select * from information_schema.cluster_log where address='123.1.1.4:1234' and address in ('123.1.1.5:1234', '123.1.1.4:1234')", + sql: "select * from information_schema.cluster_log where instance='123.1.1.4:1234' and instance in ('123.1.1.5:1234', '123.1.1.4:1234')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet("123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.4:1234"), }, { - sql: "select * from information_schema.cluster_log where address='123.1.1.4:1234' and address in ('123.1.1.5:1234', '123.1.1.6:1234')", + sql: "select * from information_schema.cluster_log where instance='123.1.1.4:1234' and instance in ('123.1.1.5:1234', '123.1.1.6:1234')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { - sql: "select * from information_schema.cluster_log where address in ('123.1.1.5:1234', '123.1.1.4:1234') and address in ('123.1.1.5:1234', '123.1.1.6:1234')", + sql: "select * from information_schema.cluster_log where instance in ('123.1.1.5:1234', '123.1.1.4:1234') and instance in ('123.1.1.5:1234', '123.1.1.6:1234')", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet("123.1.1.5:1234"), + instances: set.NewStringSet("123.1.1.5:1234"), }, { sql: `select * from information_schema.cluster_log - where address in ('123.1.1.5:1234', '123.1.1.4:1234') - and address in ('123.1.1.5:1234', '123.1.1.6:1234') + where instance in ('123.1.1.5:1234', '123.1.1.4:1234') + and instance in ('123.1.1.5:1234', '123.1.1.6:1234') and type in ('tikv', 'tidb') and type in ('pd', 'tidb')`, nodeTypes: set.NewStringSet("tidb"), - addresses: set.NewStringSet("123.1.1.5:1234"), + instances: set.NewStringSet("123.1.1.5:1234"), }, { sql: `select * from information_schema.cluster_log - where address in ('123.1.1.5:1234', '123.1.1.4:1234') - and address in ('123.1.1.5:1234', '123.1.1.6:1234') - and address in ('123.1.1.6:1234', '123.1.1.7:1234') - and address in ('123.1.1.7:1234', '123.1.1.8:1234')`, + where instance in ('123.1.1.5:1234', '123.1.1.4:1234') + and instance in ('123.1.1.5:1234', '123.1.1.6:1234') + and instance in ('123.1.1.6:1234', '123.1.1.7:1234') + and instance in ('123.1.1.7:1234', '123.1.1.8:1234')`, nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), skipRequest: true, }, { sql: "select * from information_schema.cluster_log where time='2019-10-10 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10"), endTime: timestamp(c, "2019-10-10 10:10:10"), }, { sql: "select * from information_schema.cluster_log where time>='2019-10-10 10:10:10' and time<='2019-10-11 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10"), endTime: timestamp(c, "2019-10-11 10:10:10"), }, { sql: "select * from information_schema.cluster_log where time>'2019-10-10 10:10:10' and time<'2019-10-11 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10") + 1, endTime: timestamp(c, "2019-10-11 10:10:10") - 1, }, { sql: "select * from information_schema.cluster_log where time>='2019-10-10 10:10:10' and time<'2019-10-11 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10"), endTime: timestamp(c, "2019-10-11 10:10:10") - 1, }, { sql: "select * from information_schema.cluster_log where time>='2019-10-12 10:10:10' and time<'2019-10-11 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-12 10:10:10"), endTime: timestamp(c, "2019-10-11 10:10:10") - 1, skipRequest: true, @@ -441,28 +441,28 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { { sql: "select * from information_schema.cluster_log where time>='2019-10-10 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10"), endTime: math.MaxInt64, }, { sql: "select * from information_schema.cluster_log where time>='2019-10-10 10:10:10' and time>='2019-10-11 10:10:10' and time>='2019-10-12 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-12 10:10:10"), endTime: math.MaxInt64, }, { sql: "select * from information_schema.cluster_log where time>='2019-10-10 10:10:10' and time>='2019-10-11 10:10:10' and time>='2019-10-12 10:10:10' and time='2019-10-13 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-13 10:10:10"), endTime: timestamp(c, "2019-10-13 10:10:10"), }, { sql: "select * from information_schema.cluster_log where time<='2019-10-10 10:10:10' and time='2019-10-13 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-13 10:10:10"), endTime: timestamp(c, "2019-10-10 10:10:10"), skipRequest: true, @@ -470,14 +470,14 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { { sql: "select * from information_schema.cluster_log where time='2019-10-10 10:10:10' and time<='2019-10-13 10:10:10'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10"), endTime: timestamp(c, "2019-10-10 10:10:10"), }, { sql: "select * from information_schema.cluster_log where time>='2019-10-10 10:10:10' and message like '%a%'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), startTime: timestamp(c, "2019-10-10 10:10:10"), endTime: math.MaxInt64, patterns: []string{".*a.*"}, @@ -485,30 +485,30 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { { sql: "select * from information_schema.cluster_log where message like '%a%' and message regexp '^b'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), patterns: []string{".*a.*", "^b"}, }, { sql: "select * from information_schema.cluster_log where message='gc'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), patterns: []string{"^gc$"}, }, { sql: "select * from information_schema.cluster_log where message='.*txn.*'", nodeTypes: set.NewStringSet(), - addresses: set.NewStringSet(), + instances: set.NewStringSet(), patterns: []string{"^" + regexp.QuoteMeta(".*txn.*") + "$"}, }, { sql: `select * from information_schema.cluster_log - where address in ('123.1.1.5:1234', '123.1.1.4:1234') + where instance in ('123.1.1.5:1234', '123.1.1.4:1234') and (type='tidb' or type='pd') and message like '%coprocessor%' and message regexp '.*txn=123.*' and level in ('debug', 'info', 'ERROR')`, nodeTypes: set.NewStringSet("tidb", "pd"), - addresses: set.NewStringSet("123.1.1.5:1234", "123.1.1.4:1234"), + instances: set.NewStringSet("123.1.1.5:1234", "123.1.1.4:1234"), level: set.NewStringSet("debug", "info", "error"), patterns: []string{".*coprocessor.*", ".*txn=123.*"}, }, @@ -519,7 +519,7 @@ func (s *extractorSuite) TestClusterLogTableExtractor(c *C) { clusterConfigExtractor := logicalMemTable.Extractor.(*plannercore.ClusterLogTableExtractor) c.Assert(clusterConfigExtractor.NodeTypes, DeepEquals, ca.nodeTypes, Commentf("SQL: %v", ca.sql)) - c.Assert(clusterConfigExtractor.Addresses, DeepEquals, ca.addresses, Commentf("SQL: %v", ca.sql)) + c.Assert(clusterConfigExtractor.Instances, DeepEquals, ca.instances, Commentf("SQL: %v", ca.sql)) c.Assert(clusterConfigExtractor.SkipRequest, DeepEquals, ca.skipRequest, Commentf("SQL: %v", ca.sql)) if ca.startTime > 0 { c.Assert(clusterConfigExtractor.StartTime, Equals, ca.startTime, Commentf("SQL: %v", ca.sql)) From 32caa8efa27462c2c072ca1fa47559879d4e68ee Mon Sep 17 00:00:00 2001 From: Lonng Date: Fri, 7 Feb 2020 12:05:47 +0800 Subject: [PATCH 04/14] fix diagnosis sql Signed-off-by: Lonng --- executor/diagnostics.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor/diagnostics.go b/executor/diagnostics.go index 86e3d17bef144..3da349f88fcb5 100644 --- a/executor/diagnostics.go +++ b/executor/diagnostics.go @@ -249,19 +249,19 @@ func (currentLoadInspection) inspect(_ context.Context, sctx sessionctx.Context, }, { "cpu-load1", - "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load1' and load_value>0.7;", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load1' and value>0.7;", "<0.7", commonResult, }, { "cpu-load5", - "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load5' and load_value>0.7;", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load5' and value>0.7;", "<0.7", commonResult, }, { "cpu-load15", - "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load15' and load_value>0.7;", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load15' and value>0.7;", "<0.7", commonResult, }, From ea6f8eac713d32f94afc21d1e4a8958ab60ff2cd Mon Sep 17 00:00:00 2001 From: Lonng Date: Fri, 7 Feb 2020 14:05:28 +0800 Subject: [PATCH 05/14] fix ci Signed-off-by: Lonng --- executor/cluster_reader_test.go | 34 ++++++++++++++++----------------- executor/diagnostics.go | 4 ++-- executor/diagnostics_test.go | 8 ++++---- infoschema/tables.go | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/executor/cluster_reader_test.go b/executor/cluster_reader_test.go index e4a16f3b65f4e..b5f16afa0e248 100644 --- a/executor/cluster_reader_test.go +++ b/executor/cluster_reader_test.go @@ -86,14 +86,14 @@ func (s *testClusterReaderSuite) TestMetricTableData(c *C) { c.Assert(err, IsNil) result := tk.ResultSetToResultWithCtx(ctx, rs[0], Commentf("execute sql fail")) result.Check(testkit.Rows( - "2019-12-23 20:11:35.000000 0.1 127.0.0.1:10080 0.9")) + "2019-12-23 20:11:35.000000 127.0.0.1:10080 0.9 0.1")) rs, err = tk.Se.Execute(ctx, "select * from tidb_query_duration where quantile in (0.85, 0.95);") c.Assert(err, IsNil) result = tk.ResultSetToResultWithCtx(ctx, rs[0], Commentf("execute sql fail")) result.Check(testkit.Rows( - "2019-12-23 20:11:35.000000 0.1 127.0.0.1:10080 0.85", - "2019-12-23 20:11:35.000000 0.1 127.0.0.1:10080 0.95")) + "2019-12-23 20:11:35.000000 127.0.0.1:10080 0.85 0.1", + "2019-12-23 20:11:35.000000 127.0.0.1:10080 0.95 0.1")) } func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { @@ -237,7 +237,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: "select * from information_schema.cluster_config where type='pd' or address='" + testServers[0].address + "'", + sql: "select * from information_schema.cluster_config where type='pd' or instance='" + testServers[0].address + "'", reqCount: 9, rows: flatten( rows["tidb"][0], @@ -315,7 +315,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where address='%s'`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where instance='%s'`, testServers[0].address), reqCount: 3, rows: flatten( @@ -325,7 +325,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type='tidb' and address='%s'`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type='tidb' and instance='%s'`, testServers[0].address), reqCount: 1, rows: flatten( @@ -333,7 +333,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and address='%s'`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and instance='%s'`, testServers[0].address), reqCount: 2, rows: flatten( @@ -342,7 +342,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and address in ('%s', '%s')`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and instance in ('%s', '%s')`, testServers[0].address, testServers[0].address), reqCount: 2, rows: flatten( @@ -351,7 +351,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and address in ('%s', '%s')`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and instance in ('%s', '%s')`, testServers[0].address, testServers[1].address), reqCount: 4, rows: flatten( @@ -362,17 +362,17 @@ func (s *testClusterReaderSuite) TestTiDBClusterConfig(c *C) { ), }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and type='pd' and address in ('%s', '%s')`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and type='pd' and instance in ('%s', '%s')`, testServers[0].address, testServers[1].address), reqCount: 0, }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and address in ('%s', '%s') and address='%s'`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and instance in ('%s', '%s') and instance='%s'`, testServers[0].address, testServers[1].address, testServers[2].address), reqCount: 0, }, { - sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and address in ('%s', '%s') and address='%s'`, + sql: fmt.Sprintf(`select * from information_schema.cluster_config where type in ('tidb', 'tikv') and instance in ('%s', '%s') and instance='%s'`, testServers[0].address, testServers[1].address, testServers[0].address), reqCount: 2, rows: flatten( @@ -650,7 +650,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { conditions: []string{ "time>='2019/08/26 06:19:13.011'", "time<='2019/08/26 06:21:15.011'", - fmt.Sprintf("address='%s'", testServers["pd"].address), + fmt.Sprintf("instance='%s'", testServers["pd"].address), }, expected: [][]string{ {"2019/08/26 06:19:14.011", "pd", "DEBUG", "[test log message pd 2, foo]"}, @@ -661,7 +661,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { conditions: []string{ "time>='2019/08/26 06:19:13.011'", "time<='2019/08/26 06:21:15.011'", - fmt.Sprintf("address='%s'", testServers["tidb"].address), + fmt.Sprintf("instance='%s'", testServers["tidb"].address), }, expected: [][]string{ {"2019/08/26 06:19:13.011", "tidb", "INFO", "[test log message tidb 1, foo]"}, @@ -675,7 +675,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { conditions: []string{ "time>='2019/08/26 06:19:13.011'", "time<='2019/08/26 06:21:15.011'", - fmt.Sprintf("address='%s'", testServers["tikv"].address), + fmt.Sprintf("instance='%s'", testServers["tikv"].address), }, expected: [][]string{ {"2019/08/26 06:19:13.011", "tikv", "INFO", "[test log message tikv 1, foo]"}, @@ -687,7 +687,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { conditions: []string{ "time>='2019/08/26 06:19:13.011'", "time<='2019/08/26 06:21:15.011'", - fmt.Sprintf("address in ('%s', '%s')", testServers["pd"].address, testServers["tidb"].address), + fmt.Sprintf("instance in ('%s', '%s')", testServers["pd"].address, testServers["tidb"].address), }, expected: [][]string{ {"2019/08/26 06:19:13.011", "tidb", "INFO", "[test log message tidb 1, foo]"}, @@ -819,7 +819,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { expectedRow := []string{ restime(row[0]), // time column row[1], // type column - testServers[row[1]].address, // address column + testServers[row[1]].address, // instance column strings.ToUpper(sysutil.ParseLogLevel(row[2]).String()), // level column row[3], // message column } diff --git a/executor/diagnostics.go b/executor/diagnostics.go index 3da349f88fcb5..82725a40dfb31 100644 --- a/executor/diagnostics.go +++ b/executor/diagnostics.go @@ -116,10 +116,10 @@ func (e *inspectionRetriever) retrieve(ctx context.Context, sctx sessionctx.Cont }) for _, result := range results { finalRows = append(finalRows, types.MakeDatums( - result.typ, - result.instance, name, result.item, + result.typ, + result.instance, result.actual, result.expected, result.severity, diff --git a/executor/diagnostics_test.go b/executor/diagnostics_test.go index 5d7b6800330fa..eff4d96015b0e 100644 --- a/executor/diagnostics_test.go +++ b/executor/diagnostics_test.go @@ -95,11 +95,11 @@ func (s *diagnosticsSuite) TestInspectionResult(c *C) { rows []string }{ { - sql: "select * from information_schema.inspection_result where rule in ('config', 'version')", + sql: "select rule, item, type, value, reference, detail from information_schema.inspection_result where rule in ('config', 'version')", rows: []string{ - "config coprocessor.high inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", - "config ddl.lease inconsistent consistent warning select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", - "version pd inconsistent consistent critical select * from information_schema.cluster_info where type='pd'", + "config coprocessor.high tikv inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", + "config ddl.lease tidb inconsistent consistent warning select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", + "version pd inconsistent tidb consistent critical select * from information_schema.cluster_info where type='pd'", "version tidb inconsistent consistent critical select * from information_schema.cluster_info where type='tidb'", "version tikv inconsistent consistent critical select * from information_schema.cluster_info where type='tikv'", }, diff --git a/infoschema/tables.go b/infoschema/tables.go index cd1b65cc832f2..d5fc7b7e89ba8 100755 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -1118,10 +1118,10 @@ var tableTableTiFlashReplicaCols = []columnInfo{ } var tableInspectionResultCols = []columnInfo{ - {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, - {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"RULE", mysql.TypeVarchar, 64, 0, nil, nil}, {"ITEM", mysql.TypeVarchar, 64, 0, nil, nil}, + {"TYPE", mysql.TypeVarchar, 64, 0, nil, nil}, + {"INSTANCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"VALUE", mysql.TypeVarchar, 64, 0, nil, nil}, {"REFERENCE", mysql.TypeVarchar, 64, 0, nil, nil}, {"SEVERITY", mysql.TypeVarchar, 64, 0, nil, nil}, From b4baec0659ccbe8be0d3ded14504bc0f7906ab75 Mon Sep 17 00:00:00 2001 From: Lonng Date: Fri, 7 Feb 2020 14:22:55 +0800 Subject: [PATCH 06/14] fix ci Signed-off-by: Lonng --- executor/diagnostics_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/executor/diagnostics_test.go b/executor/diagnostics_test.go index eff4d96015b0e..c6db5d516c7c1 100644 --- a/executor/diagnostics_test.go +++ b/executor/diagnostics_test.go @@ -95,34 +95,34 @@ func (s *diagnosticsSuite) TestInspectionResult(c *C) { rows []string }{ { - sql: "select rule, item, type, value, reference, detail from information_schema.inspection_result where rule in ('config', 'version')", + sql: "select rule, item, type, value, reference, severity, details from information_schema.inspection_result where rule in ('config', 'version')", rows: []string{ "config coprocessor.high tikv inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", "config ddl.lease tidb inconsistent consistent warning select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", - "version pd inconsistent tidb consistent critical select * from information_schema.cluster_info where type='pd'", - "version tidb inconsistent consistent critical select * from information_schema.cluster_info where type='tidb'", - "version tikv inconsistent consistent critical select * from information_schema.cluster_info where type='tikv'", + "version git_hash tidb inconsistent consistent critical select * from information_schema.cluster_info where type='tidb'", + "version git_hash tikv inconsistent consistent critical select * from information_schema.cluster_info where type='tikv'", + "version git_hash pd inconsistent consistent critical select * from information_schema.cluster_info where type='pd'", }, }, { - sql: "select * from information_schema.inspection_result where rule in ('config', 'version') and item in ('coprocessor.high', 'tikv')", + sql: "select rule, item, type, value, reference, severity, details from information_schema.inspection_result where rule in ('config', 'version') and item in ('coprocessor.high', 'git_hash') and type='tikv'", rows: []string{ - "config coprocessor.high inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", - "version tikv inconsistent consistent critical select * from information_schema.cluster_info where type='tikv'", + "config coprocessor.high tikv inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", + "version git_hash tikv inconsistent consistent critical select * from information_schema.cluster_info where type='tikv'", }, }, { - sql: "select * from information_schema.inspection_result where rule='config'", + sql: "select rule, item, type, value, reference, severity, details from information_schema.inspection_result where rule='config'", rows: []string{ - "config coprocessor.high inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", - "config ddl.lease inconsistent consistent warning select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", + "config coprocessor.high tikv inconsistent consistent warning select * from information_schema.cluster_config where type='tikv' and `key`='coprocessor.high'", + "config ddl.lease tidb inconsistent consistent warning select * from information_schema.cluster_config where type='tidb' and `key`='ddl.lease'", }, }, { - sql: "select * from information_schema.inspection_result where rule='version' and item in ('pd', 'tidb')", + sql: "select rule, item, type, value, reference, severity, details from information_schema.inspection_result where rule='version' and item='git_hash' and type in ('pd', 'tidb')", rows: []string{ - "version pd inconsistent consistent critical select * from information_schema.cluster_info where type='pd'", - "version tidb inconsistent consistent critical select * from information_schema.cluster_info where type='tidb'", + "version git_hash tidb inconsistent consistent critical select * from information_schema.cluster_info where type='tidb'", + "version git_hash pd inconsistent consistent critical select * from information_schema.cluster_info where type='pd'", }, }, } From f3b92f5a7cfef047333f5ea067ca11ed26e5b782 Mon Sep 17 00:00:00 2001 From: Lonng Date: Fri, 7 Feb 2020 14:50:49 +0800 Subject: [PATCH 07/14] add unit tests Signed-off-by: Lonng --- executor/diagnostics.go | 10 +++++----- executor/diagnostics_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/executor/diagnostics.go b/executor/diagnostics.go index 82725a40dfb31..f7b2cf6b29902 100644 --- a/executor/diagnostics.go +++ b/executor/diagnostics.go @@ -231,13 +231,13 @@ func (currentLoadInspection) inspect(_ context.Context, sctx sessionctx.Context, }{ { "virtual-memory-usage", - "select type, instance, value from inspection_schema.cluster_load where device_type='memory' and device_name='virtual' and load_name='used-percent' and load_value > 0.7", + "select type, instance, value from inspection_schema.cluster_load where device_type='memory' and device_name='virtual' and name='used-percent' and value > 0.7", "<0.7", commonResult, }, { "swap-memory-usage", - "select type, instance, value from inspection_schema.cluster_load where device_type='memory' and device_name='swap' and load_name='used-percent' and load_value > 0", + "select type, instance, value from inspection_schema.cluster_load where device_type='memory' and device_name='swap' and name='used-percent' and value > 0", "0", commonResult, }, @@ -249,19 +249,19 @@ func (currentLoadInspection) inspect(_ context.Context, sctx sessionctx.Context, }, { "cpu-load1", - "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load1' and value>0.7;", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and name='load1' and value>0.7;", "<0.7", commonResult, }, { "cpu-load5", - "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load5' and value>0.7;", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and name='load5' and value>0.7;", "<0.7", commonResult, }, { "cpu-load15", - "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and load_name='load15' and value>0.7;", + "select type, instance, value from inspection_schema.cluster_load where device_type='cpu' and device_name='cpu' and name='load15' and value>0.7;", "<0.7", commonResult, }, diff --git a/executor/diagnostics_test.go b/executor/diagnostics_test.go index c6db5d516c7c1..268e55194afc5 100644 --- a/executor/diagnostics_test.go +++ b/executor/diagnostics_test.go @@ -80,6 +80,24 @@ func (s *diagnosticsSuite) TestInspectionResult(c *C) { types.MakeDatums("pd", "192.168.1.33:1234", "192.168.1.33:1234", "4.0", "m234e"), }, } + // mock load + mockData[infoschema.TableClusterLoad] = variable.TableSnapshot{ + Rows: [][]types.Datum{ + types.MakeDatums("tidb", "192.168.1.11:1234", "memory", "virtual", "used-percent", "0.8"), + types.MakeDatums("tidb", "192.168.1.12:1234", "memory", "virtual", "used-percent", "0.6"), + types.MakeDatums("tidb", "192.168.1.13:1234", "memory", "swap", "used-percent", "0"), + types.MakeDatums("tikv", "192.168.1.21:1234", "memory", "swap", "used-percent", "0.6"), + types.MakeDatums("pd", "192.168.1.31:1234", "cpu", "cpu", "load1", "1.0"), + types.MakeDatums("pd", "192.168.1.32:1234", "cpu", "cpu", "load5", "0.6"), + types.MakeDatums("pd", "192.168.1.33:1234", "cpu", "cpu", "load15", "2.0"), + }, + } + mockData[infoschema.TableClusterHardware] = variable.TableSnapshot{ + Rows: [][]types.Datum{ + types.MakeDatums("tikv", "192.168.1.22:1234", "disk", "sda", "used-percent", "80"), + types.MakeDatums("tikv", "192.168.1.23:1234", "disk", "sdb", "used-percent", "50"), + }, + } ctx := context.WithValue(context.Background(), "__mockInspectionTables", mockData) fpName := "github.com/pingcap/tidb/executor/mockMergeMockInspectionTables" @@ -125,6 +143,16 @@ func (s *diagnosticsSuite) TestInspectionResult(c *C) { "version git_hash pd inconsistent consistent critical select * from information_schema.cluster_info where type='pd'", }, }, + { + sql: "select rule, item, type, instance, value, reference, severity, details from information_schema.inspection_result where rule='current-load'", + rows: []string{ + "current-load cpu-load1 pd 192.168.1.31:1234 1.0 <0.7 warning ", + "current-load cpu-load15 pd 192.168.1.33:1234 2.0 <0.7 warning ", + "current-load disk-usage tikv 192.168.1.22:1234 80 <70 warning select * from information_schema.cluster_hardware where type='tikv' and instance='192.168.1.22:1234' and device_type='disk' and device_name='sda'", + "current-load swap-memory-usage tikv 192.168.1.21:1234 0.6 0 warning ", + "current-load virtual-memory-usage tidb 192.168.1.11:1234 0.8 <0.7 warning ", + }, + }, } for _, cs := range cases { From 26c49a5086ae0e50e3a2a0c7c240e0bcf3755a57 Mon Sep 17 00:00:00 2001 From: Lonng Date: Fri, 7 Feb 2020 15:42:00 +0800 Subject: [PATCH 08/14] update sysutil Signed-off-by: Lonng --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2bfdc8bdc1bce..31b160ccc443a 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd github.com/pingcap/parser v0.0.0-20200206062121-701f4ad4e3c8 github.com/pingcap/pd v1.1.0-beta.0.20191219054547-4d65bbefbc6d - github.com/pingcap/sysutil v0.0.0-20191216090214-5f9620d22b3b + github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd github.com/pingcap/tidb-tools v3.0.6-0.20191106033616-90632dda3863+incompatible github.com/pingcap/tipb v0.0.0-20200201101609-1a2e9c441455 github.com/prometheus/client_golang v1.0.0 diff --git a/go.sum b/go.sum index 3678f1fdcd04a..4996226510422 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,8 @@ github.com/pingcap/pd v1.1.0-beta.0.20191219054547-4d65bbefbc6d h1:Ui80aiLTyd0EZ github.com/pingcap/pd v1.1.0-beta.0.20191219054547-4d65bbefbc6d/go.mod h1:CML+b1JVjN+VbDijaIcUSmuPgpDjXEY7UiOx5yDP8eE= github.com/pingcap/sysutil v0.0.0-20191216090214-5f9620d22b3b h1:EEyo/SCRswLGuSk+7SB86Ak1p8bS6HL1Mi4Dhyuv6zg= github.com/pingcap/sysutil v0.0.0-20191216090214-5f9620d22b3b/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= +github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd h1:k7CIHMFVKjHsda3PKkiN4zv++NEnexlUwiJEhryWpG0= +github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pingcap/tidb-tools v3.0.6-0.20191106033616-90632dda3863+incompatible h1:H1jg0aDWz2SLRh3hNBo2HFtnuHtudIUvBumU7syRkic= github.com/pingcap/tidb-tools v3.0.6-0.20191106033616-90632dda3863+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= github.com/pingcap/tipb v0.0.0-20190428032612-535e1abaa330/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI= From 7289ae3df80610d52b570293816cdbf6e8fd7630 Mon Sep 17 00:00:00 2001 From: Lonng Date: Mon, 10 Feb 2020 12:21:22 +0800 Subject: [PATCH 09/14] refactor unit test Signed-off-by: Lonng --- go.sum | 1 + infoschema/tables_test.go | 74 +++++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/go.sum b/go.sum index 23f1a66e3105c..17b3970269995 100644 --- a/go.sum +++ b/go.sum @@ -247,6 +247,7 @@ github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237 h1:HQagqIiBm github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 h1:tB9NOR21++IjLyVx3/PCPhWMwqGNCMQEH96A6dMZ/gc= github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v2.19.10+incompatible h1:lA4Pi29JEVIQIgATSeftHSY0rMGI9CLrl2ZvDLiahto= github.com/shirou/gopsutil v2.19.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index 313aca29f4b10..077955f6b81f3 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -977,41 +977,61 @@ func (s *testTableSuite) TestForTableTiFlashReplica(c *C) { func (s *testClusterTableSuite) TestForClusterServerInfo(c *C) { tk := testkit.NewTestKit(c, s.store) instances := []string{ - "tidb," + s.listenAddr + "," + s.listenAddr + ",mock-version,mock-githash", - "pd," + s.listenAddr + "," + s.listenAddr + ",mock-version,mock-githash", - "tikv," + s.listenAddr + "," + s.listenAddr + ",mock-version,mock-githash", + strings.Join([]string{"tidb" ,s.listenAddr,s.listenAddr ,"mock-version,mock-githash"}, ","), + strings.Join([]string{"pd" ,s.listenAddr,s.listenAddr ,"mock-version,mock-githash"}, ","), + strings.Join([]string{"tikv" ,s.listenAddr,s.listenAddr ,"mock-version,mock-githash"}, ","), } + fpExpr := `return("` + strings.Join(instances, ";") + `")` - c.Assert(failpoint.Enable("github.com/pingcap/tidb/infoschema/mockClusterInfo", fpExpr), IsNil) - defer func() { c.Assert(failpoint.Disable("github.com/pingcap/tidb/infoschema/mockClusterInfo"), IsNil) }() + fpName := "github.com/pingcap/tidb/infoschema/mockClusterInfo" + c.Assert(failpoint.Enable(fpName, fpExpr), IsNil) + defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() + + cases := []struct{ + sql string + types set.StringSet + addrs set.StringSet + names set.StringSet + } { + { + sql: "select * from information_schema.CLUSTER_LOAD;", + types: set.NewStringSet("tidb", "tikv", "pd"), + addrs:set.NewStringSet(s.listenAddr), + names: set.NewStringSet("cpu", "memory", "net", "disk"), + }, + { + sql: "select * from information_schema.CLUSTER_HARDWARE;", + types: set.NewStringSet("tidb", "tikv", "pd"), + addrs:set.NewStringSet(s.listenAddr), + names: set.NewStringSet("cpu", "memory", "net", "disk"), + }, + { + sql: "select * from information_schema.CLUSTER_SYSTEMINFO;", + types: set.NewStringSet("tidb", "tikv", "pd"), + addrs:set.NewStringSet(s.listenAddr), + names: set.NewStringSet("system"), + }, + } - checkInfoRows := func(re *testkit.Result, types, addrs, names set.StringSet) { - rows := re.Rows() + for _, cas := range cases { + result := tk.MustQuery(cas.sql) + rows := result.Rows() c.Assert(len(rows), Greater, 0) + gotTypes := set.StringSet{} + gotAddrs := set.StringSet{} + gotNames := set.StringSet{} + for _, row := range rows { - tp := row[0].(string) - addr := row[1].(string) - name := row[2].(string) - delete(types, tp) - delete(addrs, addr) - delete(names, name) + gotTypes.Insert(row[0].(string)) + gotAddrs.Insert(row[1].(string)) + gotNames.Insert(row[2].(string)) } - c.Assert(len(types), Equals, 0) - c.Assert(len(addrs), Equals, 0) - c.Assert(len(names), Equals, 0) - } - types := set.NewStringSet("tidb") - addrs := set.NewStringSet(s.listenAddr) - names := set.NewStringSet("cpu", "mem", "net", "disk") - re := tk.MustQuery("select * from information_schema.CLUSTER_LOAD;") - checkInfoRows(re, types, addrs, names) - re = tk.MustQuery("select * from information_schema.CLUSTER_HARDWARE;") - checkInfoRows(re, types, addrs, names) - re = tk.MustQuery("select * from information_schema.CLUSTER_SYSTEMINFO;") - names = set.NewStringSet("system") - checkInfoRows(re, types, addrs, names) + c.Assert(gotTypes, DeepEquals, cas.types) + c.Assert(gotAddrs, DeepEquals, cas.addrs) + c.Assert(gotNames, DeepEquals, cas.names) + } } func (s *testTableSuite) TestSystemSchemaID(c *C) { From bc9b8a822dfec2a9df026245e086e4505eebaddd Mon Sep 17 00:00:00 2001 From: Lonng Date: Mon, 10 Feb 2020 12:32:52 +0800 Subject: [PATCH 10/14] format Signed-off-by: Lonng --- infoschema/tables_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index 077955f6b81f3..ad7b583db66b6 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -977,9 +977,9 @@ func (s *testTableSuite) TestForTableTiFlashReplica(c *C) { func (s *testClusterTableSuite) TestForClusterServerInfo(c *C) { tk := testkit.NewTestKit(c, s.store) instances := []string{ - strings.Join([]string{"tidb" ,s.listenAddr,s.listenAddr ,"mock-version,mock-githash"}, ","), - strings.Join([]string{"pd" ,s.listenAddr,s.listenAddr ,"mock-version,mock-githash"}, ","), - strings.Join([]string{"tikv" ,s.listenAddr,s.listenAddr ,"mock-version,mock-githash"}, ","), + strings.Join([]string{"tidb", s.listenAddr, s.listenAddr, "mock-version,mock-githash"}, ","), + strings.Join([]string{"pd", s.listenAddr, s.listenAddr, "mock-version,mock-githash"}, ","), + strings.Join([]string{"tikv", s.listenAddr, s.listenAddr, "mock-version,mock-githash"}, ","), } fpExpr := `return("` + strings.Join(instances, ";") + `")` @@ -987,29 +987,29 @@ func (s *testClusterTableSuite) TestForClusterServerInfo(c *C) { c.Assert(failpoint.Enable(fpName, fpExpr), IsNil) defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() - cases := []struct{ - sql string + cases := []struct { + sql string types set.StringSet addrs set.StringSet names set.StringSet - } { + }{ { - sql: "select * from information_schema.CLUSTER_LOAD;", + sql: "select * from information_schema.CLUSTER_LOAD;", types: set.NewStringSet("tidb", "tikv", "pd"), - addrs:set.NewStringSet(s.listenAddr), + addrs: set.NewStringSet(s.listenAddr), names: set.NewStringSet("cpu", "memory", "net", "disk"), }, { - sql: "select * from information_schema.CLUSTER_HARDWARE;", + sql: "select * from information_schema.CLUSTER_HARDWARE;", types: set.NewStringSet("tidb", "tikv", "pd"), - addrs:set.NewStringSet(s.listenAddr), + addrs: set.NewStringSet(s.listenAddr), names: set.NewStringSet("cpu", "memory", "net", "disk"), }, { - sql: "select * from information_schema.CLUSTER_SYSTEMINFO;", + sql: "select * from information_schema.CLUSTER_SYSTEMINFO;", types: set.NewStringSet("tidb", "tikv", "pd"), - addrs:set.NewStringSet(s.listenAddr), - names: set.NewStringSet("system"), + addrs: set.NewStringSet(s.listenAddr), + names: set.NewStringSet("system"), }, } From de4a6d0b53cf2ac476c24c9fe4a4102f2a3aed21 Mon Sep 17 00:00:00 2001 From: Lonng Date: Mon, 10 Feb 2020 12:38:16 +0800 Subject: [PATCH 11/14] fix ci Signed-off-by: Lonng --- infoschema/tables_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index ad7b583db66b6..b0a027cc8646a 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -997,7 +997,7 @@ func (s *testClusterTableSuite) TestForClusterServerInfo(c *C) { sql: "select * from information_schema.CLUSTER_LOAD;", types: set.NewStringSet("tidb", "tikv", "pd"), addrs: set.NewStringSet(s.listenAddr), - names: set.NewStringSet("cpu", "memory", "net", "disk"), + names: set.NewStringSet("cpu", "memory", "net"), }, { sql: "select * from information_schema.CLUSTER_HARDWARE;", @@ -1028,9 +1028,9 @@ func (s *testClusterTableSuite) TestForClusterServerInfo(c *C) { gotNames.Insert(row[2].(string)) } - c.Assert(gotTypes, DeepEquals, cas.types) - c.Assert(gotAddrs, DeepEquals, cas.addrs) - c.Assert(gotNames, DeepEquals, cas.names) + c.Assert(gotTypes, DeepEquals, cas.types, Commentf("sql: %s", cas.sql)) + c.Assert(gotAddrs, DeepEquals, cas.addrs, Commentf("sql: %s", cas.sql)) + c.Assert(gotNames, DeepEquals, cas.names, Commentf("sql: %s", cas.sql)) } } From 5c4e7190820ab3e9faf979baaa6e9470fb243b71 Mon Sep 17 00:00:00 2001 From: Lonng Date: Mon, 10 Feb 2020 12:52:57 +0800 Subject: [PATCH 12/14] fix ci Signed-off-by: Lonng --- executor/cluster_reader_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor/cluster_reader_test.go b/executor/cluster_reader_test.go index b5f16afa0e248..bc07b35635684 100644 --- a/executor/cluster_reader_test.go +++ b/executor/cluster_reader_test.go @@ -465,7 +465,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { logtime(`2019/08/26 06:19:16.011`) + ` [trace] [test log message tidb 4, foo]`, logtime(`2019/08/26 06:19:17.011`) + ` [CRITICAL] [test log message tidb 5, foo]`, }) - s.writeTmpFile(c, testServers["tidb"].tmpDir, "tidb.log.1", []string{ + s.writeTmpFile(c, testServers["tidb"].tmpDir, "tidb-1.log", []string{ logtime(`2019/08/26 06:25:13.011`) + ` [info] [test log message tidb 10, bar]`, logtime(`2019/08/26 06:25:14.011`) + ` [debug] [test log message tidb 11, bar]`, logtime(`2019/08/26 06:25:15.011`) + ` [ERROR] [test log message tidb 12, bar]`, @@ -481,7 +481,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { logtime(`2019/08/26 06:22:16.011`) + ` [trace] [test log message tikv 4, foo]`, logtime(`2019/08/26 06:23:17.011`) + ` [CRITICAL] [test log message tikv 5, foo]`, }) - s.writeTmpFile(c, testServers["tikv"].tmpDir, "tikv.log.1", []string{ + s.writeTmpFile(c, testServers["tikv"].tmpDir, "tikv-1.log", []string{ logtime(`2019/08/26 06:24:15.011`) + ` [info] [test log message tikv 10, bar]`, logtime(`2019/08/26 06:25:16.011`) + ` [debug] [test log message tikv 11, bar]`, logtime(`2019/08/26 06:26:17.011`) + ` [ERROR] [test log message tikv 12, bar]`, @@ -497,7 +497,7 @@ func (s *testClusterReaderSuite) TestTiDBClusterLog(c *C) { logtime(`2019/08/26 06:21:16.011`) + ` [trace] [test log message pd 4, foo]`, logtime(`2019/08/26 06:22:17.011`) + ` [CRITICAL] [test log message pd 5, foo]`, }) - s.writeTmpFile(c, testServers["pd"].tmpDir, "pd.log.1", []string{ + s.writeTmpFile(c, testServers["pd"].tmpDir, "pd-1.log", []string{ logtime(`2019/08/26 06:23:13.011`) + ` [info] [test log message pd 10, bar]`, logtime(`2019/08/26 06:24:14.011`) + ` [debug] [test log message pd 11, bar]`, logtime(`2019/08/26 06:25:15.011`) + ` [ERROR] [test log message pd 12, bar]`, From 37ae7bbccf88f2d412d21ef25c501ebae8cc9303 Mon Sep 17 00:00:00 2001 From: Lonng Date: Mon, 10 Feb 2020 14:15:30 +0800 Subject: [PATCH 13/14] address comment Signed-off-by: Lonng --- executor/cluster_reader.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor/cluster_reader.go b/executor/cluster_reader.go index 860cf26339653..4b1edc62a5e07 100644 --- a/executor/cluster_reader.go +++ b/executor/cluster_reader.go @@ -432,9 +432,9 @@ func (e *clusterLogRetriever) startRetrieving(ctx context.Context, sctx sessionc return nil, err } - addresses := e.extractor.Instances + instances := e.extractor.Instances nodeTypes := e.extractor.NodeTypes - serversInfo = filterClusterServerInfo(serversInfo, nodeTypes, addresses) + serversInfo = filterClusterServerInfo(serversInfo, nodeTypes, instances) // gRPC options opt := grpc.WithInsecure() @@ -465,7 +465,7 @@ func (e *clusterLogRetriever) startRetrieving(ctx context.Context, sctx sessionc if !isFailpointTestModeSkipCheck { // To avoid search log interface overload, the user should specify at least one pattern // in normally SQL. (But in test mode we should relax this limitation) - if len(patterns) == 0 && len(levels) == 0 && len(addresses) == 0 && len(nodeTypes) == 0 { + if len(patterns) == 0 && len(levels) == 0 && len(instances) == 0 && len(nodeTypes) == 0 { return nil, errors.New("denied to scan full logs (use `SELECT * FROM cluster_log WHERE message LIKE '%'` explicitly if intentionally)") } From 29ea228c619695584f4430795ad3ee40debbf186 Mon Sep 17 00:00:00 2001 From: Lonng Date: Mon, 10 Feb 2020 15:26:01 +0800 Subject: [PATCH 14/14] go mod tidy Signed-off-by: Lonng --- go.sum | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/go.sum b/go.sum index a74f64ebfe0d5..a211e51351134 100644 --- a/go.sum +++ b/go.sum @@ -76,7 +76,6 @@ github.com/go-sql-driver/mysql v0.0.0-20170715192408-3955978caca4 h1:3DFRjZdCDhz github.com/go-sql-driver/mysql v0.0.0-20170715192408-3955978caca4/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v0.0.0-20180717141946-636bf0302bc9/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -96,8 +95,6 @@ github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -123,7 +120,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.4.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= @@ -149,7 +145,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.0.0/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -157,7 +152,6 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= -github.com/matttproud/golang_protobuf_extensions v1.0.0/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -185,6 +179,7 @@ github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKw github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.3.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= github.com/pingcap/check v0.0.0-20191107115940-caf2b9e6ccf4/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= @@ -212,11 +207,8 @@ github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd h1:CV3VsP3Z02MVtdpTMfE github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/parser v0.0.0-20200207090844-d65f5147dd9f h1:uUrZ94J2/tsmCXHjF7pItG2tMqwP4P4vMojAbI8NMRY= github.com/pingcap/parser v0.0.0-20200207090844-d65f5147dd9f/go.mod h1:9v0Edh8IbgjGYW2ArJr19E+bvL8zKahsFp+ixWeId+4= -github.com/pingcap/pd v1.1.0-beta.0.20191219054547-4d65bbefbc6d h1:Ui80aiLTyd0EZD56o2tjFRYpHfhazBjtBdKeR8UoTFY= -github.com/pingcap/pd v1.1.0-beta.0.20191219054547-4d65bbefbc6d/go.mod h1:CML+b1JVjN+VbDijaIcUSmuPgpDjXEY7UiOx5yDP8eE= github.com/pingcap/pd v1.1.0-beta.0.20200106144140-f5a7aa985497 h1:FzLErYtcXnSxtC469OuVDlgBbh0trJZzNxw0mNKzyls= github.com/pingcap/pd v1.1.0-beta.0.20200106144140-f5a7aa985497/go.mod h1:cfT/xu4Zz+Tkq95QrLgEBZ9ikRcgzy4alHqqoaTftqI= -github.com/pingcap/pd v2.1.19+incompatible/go.mod h1:nD3+EoYes4+aNNODO99ES59V83MZSI+dFbhyr667a0E= github.com/pingcap/sysutil v0.0.0-20191216090214-5f9620d22b3b h1:EEyo/SCRswLGuSk+7SB86Ak1p8bS6HL1Mi4Dhyuv6zg= github.com/pingcap/sysutil v0.0.0-20191216090214-5f9620d22b3b/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd h1:k7CIHMFVKjHsda3PKkiN4zv++NEnexlUwiJEhryWpG0= @@ -231,26 +223,20 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20180518154759-7600349dcfe1/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/procfs v0.0.0-20180612222113-7d6f385de8be/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237 h1:HQagqIiBmr8YXawX/le3+O26N+vPPC1PtjaF3mwnook= github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rleungx/pd v1.1.0-beta.0.20191226095457-5d9028d0aa90 h1:SPpOwBQqt25Sn597QgToYConcEn4ncMBTLV/cEZpnk8= -github.com/rleungx/pd v1.1.0-beta.0.20191226095457-5d9028d0aa90/go.mod h1:CML+b1JVjN+VbDijaIcUSmuPgpDjXEY7UiOx5yDP8eE= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 h1:tB9NOR21++IjLyVx3/PCPhWMwqGNCMQEH96A6dMZ/gc= @@ -263,7 +249,6 @@ github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 h1:SWV2fHctRpRrp49 github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20181020040650-a97a25d856ca h1:3fECS8atRjByijiI8yYiuwLwQ2ZxXobW7ua/8GRB3pI= github.com/shurcooL/vfsgen v0.0.0-20181020040650-a97a25d856ca/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= -github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= @@ -292,8 +277,6 @@ github.com/uber/jaeger-client-go v2.15.0+incompatible h1:NP3qsSqNxh8VYr956ur1N/1 github.com/uber/jaeger-client-go v2.15.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v1.5.0 h1:OHbgr8l656Ub3Fw5k9SWnBfIEwvoHQ+W2y+Aa9D1Uyo= github.com/uber/jaeger-lib v1.5.0/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= -github.com/ugorji/go v1.1.2/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= -github.com/ugorji/go/codec v0.0.0-20190204201341-e444a5086c43/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA= github.com/unrolled/render v0.0.0-20171102162132-65450fb6b2d3/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg= github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d h1:ggUgChAeyge4NZ4QUw6lhHsVymzwSDJOZcE0s2X8S20= github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg= @@ -303,10 +286,8 @@ github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKn github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/etcd v0.0.0-20190320044326-77d4b742cdbf/go.mod h1:KSGwdbiFchh5KIC9My2+ZVl5/3ANcwohw50dpPwa2cw= go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738 h1:lWF4f9Nypl1ZqSb4gLeh/DGvBYVaUYHuiB93teOmwgc= go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -328,11 +309,9 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.12.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/crypto v0.0.0-20180608092829-8ac0e0d97ce4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -373,7 +352,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190909082730-f460065e899a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ= golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -401,20 +379,17 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbO golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180608181217-32ee49c4dd80/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181004005441-af9cb2a35e7f/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190905072037-92dd089d5514 h1:oFSK4421fpCKRrpzIpybyBVWyht05NegY9+L/3TLAZs= google.golang.org/genproto v0.0.0-20190905072037-92dd089d5514/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/grpc v0.0.0-20180607172857-7a6a684ca69e/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/gometalinter.v2 v2.0.12/go.mod h1:NDRytsqEZyolNuAgTzJkZMkSQM7FIKyzVzGhjB/qfYo= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c/go.mod h1:3HH7i1SgMqlzxCcBmUHW657sD4Kvv9sC3HpL3YukzwA= @@ -426,7 +401,6 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=