runaway sql feature always query information_schema.tables using internal transaction
- 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)
https://github.com/pingcap/tidb/blob/d64cd8c08833b591c1d4e6fb08fa4f62ef0c7add/pkg/resourcegroup/runaway/syncer.go#L63
### 2. What did you expect to see? (Required)
Runaway resource control is running background job, querying information_schema.tables every 1s
If there are 1M tables, this single operation cause 100% CPU because scan all 1M information schema tables takes more than 1s
### 3. What did you see instead (Required)
### 4. What is your TiDB version? (Required)
Contributor guide
Research direction
Start at pkg/resourcegroup/runaway/syncer.go around line 63, where the background job queries information_schema.tables every second. Reproduce the behavior with a database containing many tables and measure the query cost and CPU usage. Done means runaway resource control no longer repeatedly causes excessive CPU from scanning all tables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100