pingcap / pingcap/tidb

copr-cache mem leak

Open
#62,763 0 comments 0 reactions 0 assignees View on GitHub
affects-6.5 affects-7.1 affects-7.5 affects-8.1 affects-8.5 affects-9.0 impact/leak report/customer severity/major sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

- set copr-cache cap to 1GB
- run tidb with memory quta 10GB
- construct sql to make copr-cache hit/update frequently
- run workload for a long time

### 2. What did you expect to see? (Required)

- no mem leak

### 3. What did you see instead (Required)

Mem leak

- the approximate mem consumption of copr-cache(red square parts) is about 1GB, which is as expect.
- the memory consumption of the model ristretto / expiringMap is large and beyond TiDB's control
- It is known that https://github.com/golang/go/issues/20135 map will not shrink automatically

```
// bucket type is a map of key to conflict.
type bucket map[uint64]uint64

// expirationMap is a map of bucket number to the corresponding bucket.
type expirationMap struct {
sync.RWMutex
buckets map[int64]bucket
}
```

Image

Image

### 4. What is your TiDB version? (Required)

since #13824

version >= v4.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.