【 TiDB 版本】
v8.1.0
【遇到的问题:问题现象及影响】
TiDB集群3个tidb-server,其中一个tidb-server节点内存不断增涨,触发了go_memstats_heap_inuse_bytes{job=“tidb”} > 1e+10告警,其他两个tidb-server节点正常。
Goroutine Count无异常。
go tool pprof heap.profile
File: tidb-server
Build ID: 121ec23f62e64cf12ab251610a96d00bde5f33fa
Type: inuse_space
Time: Nov 22, 2024 at 6:29pm (CST)
Entering interactive mode (type “help” for commands, “o” for options)
(pprof) top
Showing nodes accounting for 5.35GB, 86.04% of 6.22GB total
Dropped 1026 nodes (cum <= 0.03GB)
Showing top 10 nodes out of 174
flat flat% sum% cum cum%
3.57GB 57.33% 57.33% 3.57GB 57.33% strings.(*Builder).WriteString
0.56GB 8.94% 66.27% 0.56GB 8.94% github.com/pingcap/tidb/pkg/store/copr.(*copIteratorWorker).handleCopCache
0.48GB 7.68% 73.95% 0.56GB 8.95% github.com/pingcap/tidb/pkg/sessionctx/variable.NewSessionVars
0.24GB 3.82% 77.77% 0.24GB 3.82% github.com/pingcap/tidb/pkg/session.(*txnManager).recordEvent
0.19GB 3.01% 80.79% 0.19GB 3.01% github.com/pingcap/tidb/pkg/util/sqlescape.EscapeSQL
0.08GB 1.23% 82.02% 0.08GB 1.23% github.com/pingcap/tidb/pkg/util/memory.(*Tracker).AttachTo
0.07GB 1.09% 83.11% 0.07GB 1.09% github.com/pingcap/tidb/pkg/table/tables.adjustRowValuesBuf
0.07GB 1.05% 84.16% 0.07GB 1.05% github.com/pingcap/tidb/pkg/util/chunk.(*Column).AppendBytes
0.06GB 1.01% 85.17% 0.06GB 1.01% github.com/pingcap/tidb/pkg/util/memory.NewTracker
0.05GB 0.86% 86.04% 0.74GB 11.82% github.com/pingcap/tidb/pkg/session.createSessionWithOpt
(pprof) peek WriteString
Showing nodes accounting for 6369.94MB, 100% of 6369.94MB total
----------------------------------------------------------±------------
flat flat% sum% cum cum% calls calls% + context
----------------------------------------------------------±------------
2144.48MB 58.72% | github.com/pingcap/tidb/pkg/statistics/handle/storage.saveBucketsToStorage (inline)
1496.50MB 40.98% | github.com/pingcap/tidb/pkg/statistics/handle/storage.saveTopNToStorage (inline)
11MB 0.3% | github.com/pingcap/tidb/pkg/parser/format.(*RestoreCtx).WriteKeyWord
3651.98MB 57.33% 57.33% 3651.98MB 57.33% | strings.(*Builder).WriteString
----------------------------------------------------------±------------
【附件:截图/日志/监控】
tidb-server内存
Goroutine Count
heap.profile (4.4 MB)