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

executor, infoschema, util: add sum_errors and sum_warnings to statement summary tables #16456

Merged
merged 7 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix testcase
  • Loading branch information
djshow832 committed Apr 16, 2020
commit a81c6434e981b2cc4dac83565c1acf618a39c9c9
2 changes: 1 addition & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,9 @@ var tableStatementsSummaryCols = []columnInfo{
{name: "TABLE_NAMES", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "Involved tables"},
{name: "INDEX_NAMES", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "Used indices"},
{name: "SAMPLE_USER", tp: mysql.TypeVarchar, size: 64, comment: "Sampled user who executed these statements"},
{name: "EXEC_COUNT", tp: mysql.TypeLonglong, size: 20, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Count of executions"},
{name: "SUM_ERRORS", tp: mysql.TypeLong, size: 11, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Sum of errors"},
{name: "SUM_WARNINGS", tp: mysql.TypeLong, size: 11, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Sum of warnings"},
{name: "EXEC_COUNT", tp: mysql.TypeLonglong, size: 20, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Count of executions"},
{name: "SUM_LATENCY", tp: mysql.TypeLonglong, size: 20, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Sum latency of these statements"},
{name: "MAX_LATENCY", tp: mysql.TypeLonglong, size: 20, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Max latency of these statements"},
{name: "MIN_LATENCY", tp: mysql.TypeLonglong, size: 20, flag: mysql.NotNullFlag | mysql.UnsignedFlag, comment: "Min latency of these statements"},
Expand Down
4 changes: 2 additions & 2 deletions util/stmtsummary/statement_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,11 @@ func (ssElement *stmtSummaryByDigestElement) add(sei *StmtExecInfo, intervalSeco

// refreshInterval may change anytime, update endTime ASAP.
ssElement.endTime = ssElement.beginTime + intervalSeconds
ssElement.execCount++
if !sei.Succeed {
ssElement.sumErrors += 1
}
ssElement.sumWarnings += int(sei.StmtCtx.WarningCount())
ssElement.execCount++

// latency
ssElement.sumLatency += sei.TotalLatency
Expand Down Expand Up @@ -766,9 +766,9 @@ func (ssElement *stmtSummaryByDigestElement) toDatum(ssbd *stmtSummaryByDigest)
convertEmptyToNil(ssbd.tableNames),
convertEmptyToNil(strings.Join(ssElement.indexNames, ",")),
convertEmptyToNil(sampleUser),
ssElement.execCount,
ssElement.sumErrors,
ssElement.sumWarnings,
ssElement.execCount,
int64(ssElement.sumLatency),
int64(ssElement.maxLatency),
int64(ssElement.minLatency),
Expand Down
7 changes: 6 additions & 1 deletion util/stmtsummary/statement_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func (s *testStmtSummarySuite) TestAddStatement(c *C) {
},
MemMax: 20000,
StartTime: time.Date(2019, 1, 1, 10, 10, 20, 10, time.UTC),
Succeed: true,
}
stmtExecInfo2.StmtCtx.AddAffectedRows(200)
expectedSummaryElement.execCount++
Expand Down Expand Up @@ -323,6 +324,7 @@ func (s *testStmtSummarySuite) TestAddStatement(c *C) {
},
MemMax: 200,
StartTime: time.Date(2019, 1, 1, 10, 10, 0, 10, time.UTC),
Succeed: true,
}
stmtExecInfo3.StmtCtx.AddAffectedRows(20000)
expectedSummaryElement.execCount++
Expand Down Expand Up @@ -426,6 +428,8 @@ func matchStmtSummaryByDigest(first, second *stmtSummaryByDigest) bool {
ssElement1.samplePlan != ssElement2.samplePlan ||
ssElement1.prevSQL != ssElement2.prevSQL ||
ssElement1.execCount != ssElement2.execCount ||
ssElement1.sumErrors != ssElement2.sumErrors ||
ssElement1.sumWarnings != ssElement2.sumWarnings ||
ssElement1.sumLatency != ssElement2.sumLatency ||
ssElement1.maxLatency != ssElement2.maxLatency ||
ssElement1.minLatency != ssElement2.minLatency ||
Expand Down Expand Up @@ -569,6 +573,7 @@ func generateAnyExecInfo() *StmtExecInfo {
},
MemMax: 10000,
StartTime: time.Date(2019, 1, 1, 10, 10, 10, 10, time.UTC),
Succeed: true,
}
stmtExecInfo.StmtCtx.AddAffectedRows(10000)
return stmtExecInfo
Expand All @@ -589,7 +594,7 @@ func (s *testStmtSummarySuite) TestToDatum(c *C) {
e := types.NewTime(types.FromGoTime(time.Unix(s.ssMap.beginTimeForCurInterval+1800, 0)), mysql.TypeTimestamp, types.DefaultFsp)
t := types.NewTime(types.FromGoTime(stmtExecInfo1.StartTime), mysql.TypeTimestamp, types.DefaultFsp)
expectedDatum := []interface{}{n, e, "select", stmtExecInfo1.SchemaName, stmtExecInfo1.Digest, stmtExecInfo1.NormalizedSQL,
"db1.tb1,db2.tb2", "a", stmtExecInfo1.User, 1, int64(stmtExecInfo1.TotalLatency),
"db1.tb1,db2.tb2", "a", stmtExecInfo1.User, 1, 0, 0, int64(stmtExecInfo1.TotalLatency),
int64(stmtExecInfo1.TotalLatency), int64(stmtExecInfo1.TotalLatency), int64(stmtExecInfo1.TotalLatency),
int64(stmtExecInfo1.ParseLatency), int64(stmtExecInfo1.ParseLatency), int64(stmtExecInfo1.CompileLatency),
int64(stmtExecInfo1.CompileLatency), stmtExecInfo1.CopTasks.NumCopTasks, int64(stmtExecInfo1.CopTasks.AvgProcessTime),
Expand Down