Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: implement inspection_summary system table which organizes metrics by link/module #14810

Merged
merged 6 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1317,10 +1317,18 @@ func (b *executorBuilder) buildMemTable(v *plannercore.PhysicalMemTable) Executo
case strings.ToLower(infoschema.TableInspectionResult):
return &MemTableReaderExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()),
retriever: &inspectionRetriever{
retriever: &inspectionResultRetriever{
extractor: v.Extractor.(*plannercore.InspectionResultTableExtractor),
},
}
case strings.ToLower(infoschema.TableInspectionSummary):
return &MemTableReaderExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()),
retriever: &inspectionSummaryRetriever{
table: v.Table,
extractor: v.Extractor.(*plannercore.InspectionSummaryTableExtractor),
},
}
case strings.ToLower(infoschema.TableMetricSummary):
return &MemTableReaderExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()),
Expand Down
3 changes: 3 additions & 0 deletions executor/executor_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import (
var _ = Suite(&testExecSuite{})
var _ = SerialSuites(&testExecSerialSuite{})

// Note: it's a tricky way to export the `inspectionSummaryRules` for unit test but invisible for normal code
var InspectionSummaryRules = inspectionSummaryRules

type testExecSuite struct {
}

Expand Down
4 changes: 2 additions & 2 deletions executor/diagnostics.go → executor/inspection_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ var inspectionRules = []inspectionRule{
&thresholdCheckInspection{inspectionName: "threshold-check"},
}

type inspectionRetriever struct {
type inspectionResultRetriever struct {
dummyCloser
retrieved bool
extractor *plannercore.InspectionResultTableExtractor
}

func (e *inspectionRetriever) retrieve(ctx context.Context, sctx sessionctx.Context) ([][]types.Datum, error) {
func (e *inspectionResultRetriever) retrieve(ctx context.Context, sctx sessionctx.Context) ([][]types.Datum, error) {
if e.retrieved || e.extractor.SkipInspection {
return nil, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ import (
"github.com/pingcap/tidb/util/testkit"
)

var _ = Suite(&diagnosticsSuite{})
var _ = SerialSuites(&inspectionResultSuite{})

type diagnosticsSuite struct {
type inspectionResultSuite struct {
store kv.Storage
dom *domain.Domain
}

func (s *diagnosticsSuite) SetUpSuite(c *C) {
func (s *inspectionResultSuite) SetUpSuite(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
s.store = store
s.dom = dom
}

func (s *diagnosticsSuite) TearDownSuite(c *C) {
func (s *inspectionResultSuite) TearDownSuite(c *C) {
s.dom.Close()
s.store.Close()
}

func (s *diagnosticsSuite) TestInspectionResult(c *C) {
func (s *inspectionResultSuite) TestInspectionResult(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)

mockData := map[string]variable.TableSnapshot{}
Expand Down Expand Up @@ -166,13 +166,13 @@ func (s *diagnosticsSuite) TestInspectionResult(c *C) {
}
}

func (s *diagnosticsSuite) parseTime(c *C, se session.Session, str string) types.Time {
func (s *inspectionResultSuite) parseTime(c *C, se session.Session, str string) types.Time {
t, err := types.ParseTime(se.GetSessionVars().StmtCtx, str, mysql.TypeDatetime, types.MaxFsp)
c.Assert(err, IsNil)
return t
}

func (s *diagnosticsSuite) TestThresholdCheckInspection(c *C) {
func (s *inspectionResultSuite) TestThresholdCheckInspection(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
// mock tikv configuration.
configurations := map[string]variable.TableSnapshot{}
Expand Down Expand Up @@ -277,7 +277,7 @@ func (s *diagnosticsSuite) TestThresholdCheckInspection(c *C) {
"grpc_cpu tikv tikv-0 7.21 < 7.20, config: server.grpc-concurrency=8 select instance, sum(value) as cpu from metric_schema.tikv_thread_cpu where name like 'grpc%' and time=now() group by instance"))
}

func (s *diagnosticsSuite) TestCriticalErrorInspection(c *C) {
func (s *inspectionResultSuite) TestCriticalErrorInspection(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)

fpName := "github.com/pingcap/tidb/executor/mockMetricsTableData"
Expand Down
Loading