pingcap / pingcap/tidb

STATEMENTS_SUMMARY evict strategy can lead to strange results

Open
#49,732 2 comments 0 reactions 1 assignee Claimed by @mornyx View on GitHub
severity/moderate sig/diagnosis 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)

1. Change system variable for observe:

```sql
set @@global.tidb_stmt_summary_refresh_interval=60;
```

Run following query in a loop:

```sql
select * from t1;
select * from t2;
select * from t3;
select * from t4;
```

When there are no evict occurred, the `SQL Statements` result show in TiDB dashboard is expected,:

image

But after `set @@global.tidb_stmt_summary_max_stmt_count=8;`, the query result will be wired:

image

This is caused by the evict strategies, some SQL statements are been evicted by new query(such as `select version()`, even the query only occure once) , and then been recorded when they were reoccur. Maybe we need a better evict strategy to avoid this problem.

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

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

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

master:

```sql
+------+-----------------+-----------------+-------------+------------------------------------------+---------------------+-----------------+-----------+
| TYPE | INSTANCE | STATUS_ADDRESS | VERSION | GIT_HASH | START_TIME | UPTIME | SERVER_ID |
+------+-----------------+-----------------+-------------+------------------------------------------+---------------------+-----------------+-----------+
| tidb | 127.0.0.1:4000 | 127.0.0.1:10080 | 7.6.0-alpha | 7d33d0d226ea69ef49fb0a6786f8972e112adf4b | 2023-12-22 19:57:03 | 1h28m35.962325s | 1961 |
| pd | 127.0.0.1:2379 | 127.0.0.1:2379 | 7.6.0-alpha | 83da4c26b10e7f4e371ebc1a934fddd5981c10b0 | 2023-12-22 19:56:45 | 1h28m53.962329s | 0 |
| tikv | 127.0.0.1:20160 | 127.0.0.1:20180 | 7.6.0-alpha | 4626f8d774b720a10b094cc39e0a78b3cd27dd2b | 2023-12-22 19:56:48 | 1h28m50.96233s | 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.