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

infoschema, util/stmtsummary: enhance statements_summary. #25031

Merged
merged 123 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 118 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
1a96cbb
util/kvcache: enhance LRU Cache
ClSlaid Apr 23, 2021
0c8920a
Merge branch 'master' into master
ClSlaid Apr 23, 2021
25ae806
Merge branch 'master' into master
ClSlaid Apr 23, 2021
529e346
Util/kvcache: Typo fix
ClSlaid Apr 23, 2021
38fa019
util/kvcache/simple_lru.go: typo fix
ClSlaid Apr 25, 2021
d78ca46
util/kvcache: fix test
ClSlaid Apr 25, 2021
1cddd8f
Merge branch 'master' into master
crazycs520 Apr 25, 2021
33d865f
util/kvcache: synced onEvict func -> asynced
ClSlaid Apr 25, 2021
2d75e37
Merge branch 'master' of github.com:ClSlaid/tidb
ClSlaid Apr 25, 2021
05703d8
util/kvcache: formatted
ClSlaid Apr 25, 2021
eaf1caa
Merge branch 'master' into master
crazycs520 Apr 25, 2021
0163613
Merge branch 'master' into master
ti-chi-bot Apr 25, 2021
0935f75
Merge branch 'master' into master
ti-chi-bot Apr 25, 2021
c0227b6
Statements Summary Evicted Prototype Commit
ClSlaid Apr 30, 2021
0a168fe
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid Apr 30, 2021
b447b86
Fix STATEMENTS_SUMMARY_EVICTED
ClSlaid May 8, 2021
8e8792b
util/stmtsummary: Fix evicted.go
ClSlaid May 10, 2021
2a8ed11
Merge branch 'pingcap:master' into master
ClSlaid May 10, 2021
12b6a87
Merge branch 'master' into master
ClSlaid May 10, 2021
373d344
util/stmtsummary: Delete debug code
ClSlaid May 10, 2021
0f24624
util/stmtsummary: add test to EVICTED_COUNT
ClSlaid May 11, 2021
e2a18b1
util/stmtsummary: Add test to evicted count
ClSlaid May 12, 2021
6b7da7e
go.sum: disable fail-point
ClSlaid May 12, 2021
ebad974
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 12, 2021
3fcd196
fix merge problems
ClSlaid May 12, 2021
073ff06
clean up evicted count
ClSlaid May 14, 2021
32e8df9
typo fix
ClSlaid May 14, 2021
1092e72
performance improve and typo fix
ClSlaid May 14, 2021
7e8a8d8
simplify logic in addEvicted
ClSlaid May 17, 2021
252b43a
beautify evicted.go && typo fix
ClSlaid May 17, 2021
015b145
fix nil pointer bug in evicted.go
ClSlaid May 19, 2021
e061027
fix zero quota test for kvcache
ClSlaid May 20, 2021
d3bf818
Add test to evicted.go and some bug fixes
ClSlaid May 20, 2021
f59155b
typo fix in executor and infoschema
ClSlaid May 20, 2021
efcad35
typo fix
ClSlaid May 21, 2021
80167a3
try fix git merge problem
ClSlaid May 21, 2021
dbc94c7
Add more test to evicted count
ClSlaid May 21, 2021
756c53e
evicted test full cover
ClSlaid May 24, 2021
43a4adc
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 24, 2021
be4b4e4
fix merge conflict
ClSlaid May 24, 2021
c6ce248
fix nil pointer problem
ClSlaid May 24, 2021
a8be817
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 24, 2021
fdec81a
test refactoring
ClSlaid May 24, 2021
01a92a4
format and add license.
ClSlaid May 24, 2021
9c503e5
fix empty table error and clean up useless codes.
ClSlaid May 25, 2021
b2278b2
Add test to table and more test to evicted count
ClSlaid May 25, 2021
d3ea973
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 25, 2021
a3ed839
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
9b243a5
typo fix
ClSlaid May 26, 2021
eaffa1c
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
413ed0d
make check
ClSlaid May 26, 2021
c91e5e3
OUTDATED AGAIN???: Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
0bd1f5e
fix go.sum
ClSlaid May 26, 2021
f282833
try fix data racing
ClSlaid May 26, 2021
16c83f9
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
cca919b
try fix data racing.
ClSlaid May 26, 2021
52cb27b
try fix data racing again.
ClSlaid May 26, 2021
a31059d
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
4c9e65f
Merge branch 'master' into master
crazycs520 May 27, 2021
b7a87e1
try fix data racing again again.
ClSlaid May 27, 2021
5725827
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 27, 2021
b0776f5
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 27, 2021
b50b213
revoke change in unrelated files.
ClSlaid May 27, 2021
3b9fa88
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 27, 2021
cafa16a
Merge branch 'master' into master
crazycs520 May 28, 2021
f880324
change interval in tables_test.go
ClSlaid May 28, 2021
f740b34
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 28, 2021
6c69920
Merge branch 'master' into master
ti-chi-bot May 28, 2021
d8b32ad
Merge branch 'master' of github.com:pingcap/tidb into fire
ClSlaid Jun 1, 2021
4629224
add `other` record to CurrentDatum and HistoryDatum
ClSlaid Jun 1, 2021
184b359
add more test
ClSlaid Jun 2, 2021
39655fc
Merge branch 'master' of github.com:pingcap/tidb into fire
ClSlaid Jun 2, 2021
51a56b1
add clean-up in test.
ClSlaid Jun 2, 2021
4d633c4
Merge branch 'master' into fire
ClSlaid Jun 2, 2021
528db85
Merge branch 'master' into fire
ClSlaid Jun 2, 2021
9f2783f
typo fixes.
ClSlaid Jun 4, 2021
7500c7c
Merge branch 'fire' of github.com:ClSlaid/tidb into fire
ClSlaid Jun 4, 2021
af77055
typo fix...
ClSlaid Jun 4, 2021
3b13b59
Merge branch 'master' into fire
ClSlaid Jun 7, 2021
6af7eed
Merge branch 'master' into fire
ClSlaid Jun 7, 2021
2935d60
fix CommitBackoffTime in statement_summary_test
ClSlaid Jun 7, 2021
1b10912
Merge branch 'master' into fire
ClSlaid Jun 7, 2021
3bfd7e1
fix duplicated code and typo fix
ClSlaid Jun 7, 2021
53423a3
Merge branch 'fire' of github.com:ClSlaid/tidb into fire
ClSlaid Jun 7, 2021
322d938
improve legibility && fix typo error.😩
ClSlaid Jun 7, 2021
0802bd5
typo fix
ClSlaid Jun 7, 2021
f516fd3
move 2 functions to test.go
ClSlaid Jun 7, 2021
03e7d21
add test for addInfo()
ClSlaid Jun 8, 2021
a0601b6
Merge branch 'master' of github.com:pingcap/tidb into fire
ClSlaid Jun 8, 2021
5101038
Merge branch 'master' of github.com:pingcap/tidb into fire
ClSlaid Jun 8, 2021
3952c98
add integrated test
ClSlaid Jun 8, 2021
e9779fa
try fix lock problem
ClSlaid Jun 8, 2021
d0b4fde
Merge branch 'master' of github.com:pingcap/tidb into fire
ClSlaid Jun 8, 2021
27ee905
clean side effects in tables_test.go
ClSlaid Jun 8, 2021
2faf184
change SCHEMA_NAME and DIGEST to NULL
ClSlaid Jun 8, 2021
2ea3d3f
Merge branch 'master' of github.com:pingcap/tidb into fire
ClSlaid Jun 8, 2021
fc01d92
typo fix
ClSlaid Jun 8, 2021
b5a3aac
typo fix
ClSlaid Jun 8, 2021
f71f3ab
Merge branch 'master' into fire
ClSlaid Jun 8, 2021
49985cd
Merge branch 'master' into fire
ClSlaid Jun 8, 2021
0f920b2
typo fix...
ClSlaid Jun 8, 2021
c19b20a
Merge branch 'fire' of github.com:ClSlaid/tidb into fire
ClSlaid Jun 8, 2021
fbb9f79
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
b95f833
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
4de43c7
typo fix
ClSlaid Jun 9, 2021
6544e56
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
9eccd82
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
4936831
shorten lock range
ClSlaid Jun 9, 2021
b823bb7
Merge branch 'fire' of github.com:ClSlaid/tidb into fire
ClSlaid Jun 9, 2021
7044744
remove flag in stmtSummaryDigest
ClSlaid Jun 9, 2021
4aefe6f
fix append nil
ClSlaid Jun 9, 2021
9889df9
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
46620d1
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
ab0cbd8
mutex issues :(
ClSlaid Jun 9, 2021
5824872
Merge branch 'master' into fire
ClSlaid Jun 9, 2021
39b1f06
Merge branch 'fire' of github.com:ClSlaid/tidb into fire
ClSlaid Jun 9, 2021
337161b
fix firstSeen
ClSlaid Jun 10, 2021
39daceb
fmt
ClSlaid Jun 10, 2021
8f0b757
Merge branch 'master' into fire
ClSlaid Jun 10, 2021
ce03218
Merge branch 'master' into fire
ClSlaid Jun 10, 2021
de53695
Merge branch 'master' into fire
ti-chi-bot Jun 11, 2021
32787d4
Merge branch 'master' into fire
ti-chi-bot Jun 11, 2021
e7b8aff
Merge branch 'master' into fire
ti-chi-bot Jun 11, 2021
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
4 changes: 2 additions & 2 deletions infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,8 @@ var tableStatementsSummaryCols = []columnInfo{
{name: "SUMMARY_BEGIN_TIME", tp: mysql.TypeTimestamp, size: 26, flag: mysql.NotNullFlag, comment: "Begin time of this summary"},
{name: "SUMMARY_END_TIME", tp: mysql.TypeTimestamp, size: 26, flag: mysql.NotNullFlag, comment: "End time of this summary"},
{name: "STMT_TYPE", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, comment: "Statement type"},
{name: "SCHEMA_NAME", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, comment: "Current schema"},
{name: "DIGEST", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag},
{name: "SCHEMA_NAME", tp: mysql.TypeVarchar, size: 64, comment: "Current schema"},
{name: "DIGEST", tp: mysql.TypeVarchar, size: 64},
{name: "DIGEST_TEXT", tp: mysql.TypeBlob, size: types.UnspecifiedLength, flag: mysql.NotNullFlag, comment: "Normalized statement"},
{name: "TABLE_NAMES", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "Involved tables"},
{name: "INDEX_NAMES", tp: mysql.TypeBlob, size: types.UnspecifiedLength, comment: "Used indices"},
Expand Down
65 changes: 65 additions & 0 deletions infoschema/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,71 @@ func (s *testTableSuite) TestSimpleStmtSummaryEvictedCount(c *C) {
tk.MustExec("set global tidb_stmt_summary_refresh_interval = 1800")
}

func (s *testTableSuite) TestStmtSummaryTableOther(c *C) {
interval := int64(1800)
tk := s.newTestKitWithRoot(c)
tk.MustExec(fmt.Sprintf("set global tidb_stmt_summary_refresh_interval=%v", interval))
tk.MustExec("set global tidb_enable_stmt_summary=0")
tk.MustExec("set global tidb_enable_stmt_summary=1")
// set stmt size to 1
// first sql
tk.MustExec("set global tidb_stmt_summary_max_stmt_count=1")
defer tk.MustExec("set global tidb_stmt_summary_max_stmt_count=100")
// second sql, evict first sql from stmt_summary
tk.MustExec("show databases;")
// third sql, evict second sql from stmt_summary
tk.MustQuery("SELECT DIGEST_TEXT, DIGEST FROM `INFORMATION_SCHEMA`.`STATEMENTS_SUMMARY`;").
Check(testkit.Rows(
// digest in cache
// "show databases ;"
"show databases ; dcd020298c5f79e8dc9d63b3098083601614a04a52db458738347d15ea5712a1",
// digest evicted
" <nil>",
))
// forth sql, evict third sql from stmt_summary
tk.MustQuery("SELECT SCHEMA_NAME FROM `INFORMATION_SCHEMA`.`STATEMENTS_SUMMARY`;").
Check(testkit.Rows(
// digest in cache
"test", // select xx from yy;
// digest evicted
"<nil>",
))
}

func (s *testTableSuite) TestStmtSummaryHistoryTableOther(c *C) {
tk := s.newTestKitWithRoot(c)
// disable refreshing summary
interval := int64(9999)
tk.MustExec("set global tidb_stmt_summary_max_stmt_count = 1")
defer tk.MustExec("set global tidb_stmt_summary_max_stmt_count = 100")
tk.MustExec(fmt.Sprintf("set global tidb_stmt_summary_refresh_interval = %v", interval))
defer tk.MustExec(fmt.Sprintf("set global tidb_stmt_summary_refresh_interval = %v", 1800))

tk.MustExec("set global tidb_enable_stmt_summary = 0")
tk.MustExec("set global tidb_enable_stmt_summary = 1")
// first sql
tk.MustExec("set global tidb_stmt_summary_max_stmt_count=1")
// second sql, evict first sql from stmt_summary
tk.MustExec("show databases;")
// third sql, evict second sql from stmt_summary
tk.MustQuery("SELECT DIGEST_TEXT, DIGEST FROM `INFORMATION_SCHEMA`.`STATEMENTS_SUMMARY_HISTORY`;").
Check(testkit.Rows(
// digest in cache
// "show databases ;"
"show databases ; dcd020298c5f79e8dc9d63b3098083601614a04a52db458738347d15ea5712a1",
// digest evicted
" <nil>",
))
// forth sql, evict third sql from stmt_summary
tk.MustQuery("SELECT SCHEMA_NAME FROM `INFORMATION_SCHEMA`.`STATEMENTS_SUMMARY_HISTORY`;").
Check(testkit.Rows(
// digest in cache
"test", // select xx from yy;
// digest evicted
"<nil>",
))
}

func (s *testTableSuite) TestPerformanceSchemaforPlanCache(c *C) {
orgEnable := plannercore.PreparedPlanCacheEnabled()
defer func() {
Expand Down
229 changes: 228 additions & 1 deletion util/stmtsummary/evicted.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ package stmtsummary

import (
"container/list"
"math"
"sync"
"time"

"github.com/pingcap/parser/mysql"
Expand All @@ -23,6 +25,7 @@ import (

// stmtSummaryByDigestEvicted contents digests evicted from stmtSummaryByDigestMap
type stmtSummaryByDigestEvicted struct {
sync.Mutex
// record evicted data in intervals
// latest history data is Back()
history *list.List
Expand All @@ -34,8 +37,10 @@ type stmtSummaryByDigestEvictedElement struct {
beginTime int64
// endTime is the end time of current interval
endTime int64
// *Kinds* of digest being evicted
// digestKeyMap contains *Kinds* of digest being evicted
digestKeyMap map[string]struct{}
// otherSummary contains summed up information of evicted elements
otherSummary *stmtSummaryByDigestElement
}

// spawn a new pointer to stmtSummaryByDigestEvicted
Expand All @@ -51,6 +56,14 @@ func newStmtSummaryByDigestEvictedElement(beginTime int64, endTime int64) *stmtS
beginTime: beginTime,
endTime: endTime,
digestKeyMap: make(map[string]struct{}),
otherSummary: &stmtSummaryByDigestElement{
beginTime: beginTime,
endTime: endTime,
authUsers: make(map[string]struct{}),
minLatency: time.Duration(math.MaxInt64),
backoffTypes: make(map[string]int),
firstSeen: time.Unix(endTime, 0),
},
}
}

Expand All @@ -63,6 +76,9 @@ func (ssbde *stmtSummaryByDigestEvicted) AddEvicted(evictedKey *stmtSummaryByDig
evictedValue.Lock()
defer evictedValue.Unlock()

ssbde.Lock()
defer ssbde.Unlock()
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved

if evictedValue.history == nil {
return
}
Expand Down Expand Up @@ -130,13 +146,16 @@ func (ssbde *stmtSummaryByDigestEvicted) AddEvicted(evictedKey *stmtSummaryByDig

// Clear up all records in stmtSummaryByDigestEvicted
func (ssbde *stmtSummaryByDigestEvicted) Clear() {
ssbde.Lock()
defer ssbde.Unlock()
ssbde.history.Init()
}

// add an evicted record to stmtSummaryByDigestEvictedElement
func (seElement *stmtSummaryByDigestEvictedElement) addEvicted(digestKey *stmtSummaryByDigestKey, digestValue *stmtSummaryByDigestElement) {
if digestKey != nil {
seElement.digestKeyMap[string(digestKey.Hash())] = struct{}{}
addInfo(seElement.otherSummary, digestValue)
}
}

Expand Down Expand Up @@ -190,3 +209,211 @@ func (seElement *stmtSummaryByDigestEvictedElement) toEvictedCountDatum() []type
func (ssMap *stmtSummaryByDigestMap) ToEvictedCountDatum() [][]types.Datum {
return ssMap.other.ToEvictedCountDatum()
}

func (ssbde *stmtSummaryByDigestEvicted) toCurrentDatum() []types.Datum {
var seElement *stmtSummaryByDigestEvictedElement

ssbde.Lock()
if ssbde.history.Len() > 0 {
seElement = ssbde.history.Back().Value.(*stmtSummaryByDigestEvictedElement)
}
ssbde.Unlock()

if seElement == nil {
return nil
}

return seElement.toDatum()
}

func (ssbde *stmtSummaryByDigestEvicted) toHistoryDatum(historySize int) [][]types.Datum {
// Collect all history summaries to an array.
ssbde.Lock()
seElements := ssbde.collectHistorySummaries(historySize)
ssbde.Unlock()
rows := make([][]types.Datum, 0, len(seElements))

for _, seElement := range seElements {
rows = append(rows, seElement.toDatum())
}
return rows
}

func (ssbde *stmtSummaryByDigestEvicted) collectHistorySummaries(historySize int) []*stmtSummaryByDigestEvictedElement {
lst := make([]*stmtSummaryByDigestEvictedElement, 0, ssbde.history.Len())
for element := ssbde.history.Front(); element != nil && len(lst) < historySize; element = element.Next() {
seElement := element.Value.(*stmtSummaryByDigestEvictedElement)
lst = append(lst, seElement)
}
return lst
}

func (seElement *stmtSummaryByDigestEvictedElement) toDatum() []types.Datum {
return seElement.otherSummary.toDatum(new(stmtSummaryByDigest))
}

// addInfo adds information in addWith into addTo.
func addInfo(addTo *stmtSummaryByDigestElement, addWith *stmtSummaryByDigestElement) {
addTo.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Will addWith be modified at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this struct is huge, so I passed its address to this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, my point is locking. Will it cause data race?

Copy link
Contributor Author

@ClSlaid ClSlaid Jun 10, 2021

Choose a reason for hiding this comment

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

addWith has been locked outside the function, in stmtSummaryByDigestEvicted.AddEvicted() at line 90 in util/evicted.go, so no lock needed here.

defer addTo.Unlock()

// user
for user := range addWith.authUsers {
addTo.authUsers[user] = struct{}{}
}

// execCount and sumWarnings
addTo.execCount += addWith.execCount
addTo.sumWarnings += addWith.sumWarnings

// latency
addTo.sumLatency += addWith.sumLatency
if addTo.maxLatency < addWith.maxLatency {
addTo.maxLatency = addWith.maxLatency
}
if addTo.minLatency > addWith.minLatency {
addTo.minLatency = addWith.minLatency
}
addTo.sumParseLatency += addWith.sumParseLatency
if addTo.maxParseLatency < addWith.maxParseLatency {
addTo.maxParseLatency = addWith.maxParseLatency
}
addTo.sumCompileLatency += addWith.sumCompileLatency
if addTo.maxCompileLatency < addWith.maxCompileLatency {
addTo.maxCompileLatency = addWith.maxCompileLatency
}

// coprocessor
addTo.sumNumCopTasks += addWith.sumNumCopTasks
if addTo.maxCopProcessTime < addWith.maxCopProcessTime {
addTo.maxCopProcessTime = addWith.maxCopProcessTime
addTo.maxCopProcessAddress = addWith.maxCopProcessAddress
}
if addTo.maxCopWaitTime < addWith.maxCopWaitTime {
addTo.maxCopWaitTime = addWith.maxCopWaitTime
addTo.maxCopWaitAddress = addWith.maxCopWaitAddress
}

// TiKV
addTo.sumProcessTime += addWith.sumProcessTime
if addTo.maxProcessTime < addWith.maxProcessTime {
addTo.maxProcessTime = addWith.maxProcessTime
}
addTo.sumWaitTime += addWith.sumWaitTime
if addTo.maxWaitTime < addWith.maxWaitTime {
addTo.maxWaitTime = addWith.maxWaitTime
}
addTo.sumBackoffTime += addWith.sumBackoffTime
if addTo.maxBackoffTime < addWith.maxBackoffTime {
addTo.maxBackoffTime = addWith.maxBackoffTime
}

addTo.sumTotalKeys += addWith.sumTotalKeys
if addTo.maxTotalKeys < addWith.maxTotalKeys {
addTo.maxTotalKeys = addWith.maxTotalKeys
}
addTo.sumProcessedKeys += addWith.sumProcessedKeys
if addTo.maxProcessedKeys < addWith.maxProcessedKeys {
addTo.maxProcessedKeys = addWith.maxProcessedKeys
}
addTo.sumRocksdbDeleteSkippedCount += addWith.sumRocksdbDeleteSkippedCount
if addTo.maxRocksdbDeleteSkippedCount < addWith.maxRocksdbDeleteSkippedCount {
addTo.maxRocksdbDeleteSkippedCount = addWith.maxRocksdbDeleteSkippedCount
}
addTo.sumRocksdbKeySkippedCount += addWith.sumRocksdbKeySkippedCount
if addTo.maxRocksdbKeySkippedCount < addWith.maxRocksdbKeySkippedCount {
addTo.maxRocksdbKeySkippedCount = addWith.maxRocksdbKeySkippedCount
}
addTo.sumRocksdbBlockCacheHitCount += addWith.sumRocksdbBlockCacheHitCount
if addTo.maxRocksdbBlockCacheHitCount < addWith.maxRocksdbBlockCacheHitCount {
addTo.maxRocksdbBlockCacheHitCount = addWith.maxRocksdbBlockCacheHitCount
}
addTo.sumRocksdbBlockReadCount += addWith.sumRocksdbBlockReadCount
if addTo.maxRocksdbBlockReadCount < addWith.maxRocksdbBlockReadCount {
addTo.maxRocksdbBlockReadCount = addWith.maxRocksdbBlockReadCount
}
addTo.sumRocksdbBlockReadByte += addWith.sumRocksdbBlockReadByte
if addTo.maxRocksdbBlockReadByte < addWith.maxRocksdbBlockReadByte {
addTo.maxRocksdbBlockReadByte = addWith.maxRocksdbBlockReadByte
}

// txn
addTo.commitCount += addWith.commitCount
addTo.sumPrewriteTime += addWith.sumPrewriteTime
if addTo.maxPrewriteTime < addWith.maxPrewriteTime {
addTo.maxPrewriteTime = addWith.maxPrewriteTime
}
addTo.sumCommitTime += addWith.sumCommitTime
if addTo.maxCommitTime < addWith.maxCommitTime {
addTo.maxCommitTime = addWith.maxCommitTime
}
addTo.sumGetCommitTsTime += addWith.sumGetCommitTsTime
if addTo.maxGetCommitTsTime < addWith.maxGetCommitTsTime {
addTo.maxGetCommitTsTime = addWith.maxGetCommitTsTime
}
addTo.sumCommitBackoffTime += addWith.sumCommitBackoffTime
if addTo.maxCommitBackoffTime < addWith.maxCommitBackoffTime {
addTo.maxCommitBackoffTime = addWith.maxCommitBackoffTime
}
addTo.sumResolveLockTime += addWith.sumResolveLockTime
if addTo.maxResolveLockTime < addWith.maxResolveLockTime {
addTo.maxResolveLockTime = addWith.maxResolveLockTime
}
addTo.sumLocalLatchTime += addWith.sumLocalLatchTime
if addTo.maxLocalLatchTime < addWith.maxLocalLatchTime {
addTo.maxLocalLatchTime = addWith.maxLocalLatchTime
}
addTo.sumWriteKeys += addWith.sumWriteKeys
if addTo.maxWriteKeys < addWith.maxWriteKeys {
addTo.maxWriteKeys = addWith.maxWriteKeys
}
addTo.sumWriteSize += addWith.sumWriteSize
if addTo.maxWriteSize < addWith.maxWriteSize {
addTo.maxWriteSize = addWith.maxWriteSize
}
addTo.sumPrewriteRegionNum += addWith.sumPrewriteRegionNum
if addTo.maxPrewriteRegionNum < addWith.maxPrewriteRegionNum {
addTo.maxPrewriteRegionNum = addWith.maxPrewriteRegionNum
}
addTo.sumTxnRetry += addWith.sumTxnRetry
if addTo.maxTxnRetry < addWith.maxTxnRetry {
addTo.maxTxnRetry = addWith.maxTxnRetry
}
addTo.sumBackoffTimes += addWith.sumBackoffTimes
for backoffType, backoffValue := range addWith.backoffTypes {
_, ok := addTo.backoffTypes[backoffType]
if ok {
addTo.backoffTypes[backoffType] += backoffValue
} else {
addTo.backoffTypes[backoffType] = backoffValue
}
}

// plan cache
addTo.planCacheHits += addWith.planCacheHits

// other
addTo.sumAffectedRows += addWith.sumAffectedRows
addTo.sumMem += addWith.sumMem
if addTo.maxMem < addWith.maxMem {
addTo.maxMem = addWith.maxMem
}
addTo.sumDisk += addWith.sumDisk
if addTo.maxDisk < addWith.maxDisk {
addTo.maxDisk = addWith.maxDisk
}
if addTo.firstSeen.After(addWith.firstSeen) {
addTo.firstSeen = addWith.firstSeen
}
if addTo.lastSeen.Before(addWith.lastSeen) {
addTo.lastSeen = addWith.lastSeen
}
addTo.execRetryCount += addWith.execRetryCount
addTo.execRetryTime += addWith.execRetryTime
addTo.sumKVTotal += addWith.sumKVTotal
addTo.sumPDTotal += addWith.sumPDTotal
addTo.sumBackoffTotal += addWith.sumBackoffTotal
addTo.sumWriteSQLRespTotal += addWith.sumWriteSQLRespTotal

addTo.sumErrors += addWith.sumErrors
}
Loading