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

*: specify time range via TIME_RANGE hint for metrics/inspection tables #14874

Merged
merged 11 commits into from
Feb 21, 2020
Merged

*: specify time range via TIME_RANGE hint for metrics/inspection tables #14874

merged 11 commits into from
Feb 21, 2020

Conversation

lonng
Copy link
Contributor

@lonng lonng commented Feb 20, 2020

Signed-off-by: Lonng heng@lonng.org

What problem does this PR solve?

This PR refactors inspection/metrics system tables and improve internal consistency:

  1. Unify field naming.
  2. Separate instance to an individual column from labels.
  3. Rename metric_schema to metrics_schema.
  4. Use TIME_RANGE hint to specify the time range for metrics summary tables instead of using a redundant column time.

What is changed and how it works?

Add a QueryTimeRange for memory table executor and give the hint to retrievers.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Release note

  • No need.

@lonng lonng requested a review from a team as a code owner February 20, 2020 10:18
@ghost ghost requested review from francis0407 and alivxxx and removed request for a team February 20, 2020 10:18
@lonng
Copy link
Contributor Author

lonng commented Feb 20, 2020

/run-all-tests

Signed-off-by: Lonng <heng@lonng.org>
@lonng lonng changed the title [WIP] refactor the metrics related system tables *: specify time range via TIME_RANGE hint for metrics/inspection tables Feb 20, 2020
Signed-off-by: Lonng <heng@lonng.org>
@lonng lonng added the sig/execution SIG execution label Feb 21, 2020
@lonng lonng added this to the v4.0.0-beta.1 milestone Feb 21, 2020
Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
return nil, meta.ErrTableNotExists
def, found := infoschema.MetricTableMap[name]
if !found {
sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("metrics table: %s not found34", name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("metrics table: %s not found34", name))
sctx.GetSessionVars().StmtCtx.AppendWarning(fmt.Errorf("metrics table: %s not found", name))

@@ -2739,7 +2746,40 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
return result, nil
}

func (b *PlanBuilder) buildMemTable(ctx context.Context, dbName model.CIStr, tableInfo *model.TableInfo) (LogicalPlan, error) {
func (b *PlanBuilder) timeRangeForSummaryTable() QueryTimeRange {
const defaultSummaryDuration = 30 * time.Minute
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this a global variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a good idea because this const will not share with other functions.

}
e.LabelConditions = extractCols
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we store extractCols to e.LabelConditions, even skipRequest is true?
For avoiding check e.LabelConditions == nil after use this Extract function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cols always nil if skipRequest==true.

Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
@Deardrops
Copy link
Contributor

LGTM

@lonng
Copy link
Contributor Author

lonng commented Feb 21, 2020

/run-all-tests

@lonng
Copy link
Contributor Author

lonng commented Feb 21, 2020

/run-common-test tidb-test=pr/992

Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@lonng
Copy link
Contributor Author

lonng commented Feb 21, 2020

/run-integration-common-test tidb-test=pr/992

@lonng lonng merged commit 27b280d into pingcap:master Feb 21, 2020
@lonng lonng deleted the refactor-metrics-tables branch February 21, 2020 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants