insertTableStats2KV failed for Duplicate entry when insert into mysql.stats_histograms
- 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)
In one workload, we drop old partition and create partition every 20 minutes to maintain the fixed number of partitions(100)in the table, and we always insert value to the newest partition. we have some tables(10) like this.
we found some partitions stats meta are missing, when open the debug log, there is some log about the `insertTableStats2KV`
`tidb-2022-07-05T14-13-59.621.log:[2022/07/05 14:11:48.686 +08:00] [DEBUG] [domain.go:1464] ["handle ddl event failed"] [error="[kv:1062]Duplicate entry '3607-0-1' for key 'tbl'"]`.
the incremental collection of statistics https://github.com/pingcap/tidb/blob/f5d3b0272c82a74ca626bd0883df5e93a74e48cd/statistics/handle/update.go#L568
maybe influence the add partition ddl initial statistics
https://github.com/pingcap/tidb/blob/f5d3b0272c82a74ca626bd0883df5e93a74e48cd/statistics/handle/ddl.go#L185
### 2. What did you expect to see? (Required)
There are no missing stats meta
### 3. What did you see instead (Required)
some partitions stats meta are missing
### 4. What is your TiDB version? (Required)
master
Contributor guide
Assessment
This issue has not been assessed yet.