indexmerge exits slowly when `Out Of Memory Quota` panic is triggered
- 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)
TiDB crashed because of OOM.
- From the log, we know that the global memory controller sent the kill signal to query with top 1 memory usage successfully, and trigger the cancelAction successfully.
```
[2023/03/14 01:32:16.740 +00:00] [WARN] [servermemorylimit.go:126] ["global memory controller tries to kill the top1 memory consumer"] [connID=8123979156334580095] ["sql digest"=] ["sql text"="SELECT xxx"] [tidb_server_memory_limit=11510510320] ["heap inuse"=13101236224] ["sql memory usage"=4235421387]2023-03-14 09:32:16
[2023/03/14 01:32:17.027 +00:00] [WARN] [tracker.go:458] ["global memory controller, NeedKill signal is received successfully"] [connID=8123979156334580095]
```
- But the query exit slowly, thus blocking the global memory controller from killing the next sql, and causing the OOM.
No log like `global memory controller killed the top1 memory consumer successfully` was printed before the OOM happened.
- The query that blocks the global memory controller used IndexMerge.
### 2. What did you expect to see? (Required)
### 3. What did you see instead (Required)
### 4. What is your TiDB version? (Required)
release-6.5
Contributor guide
Assessment
This issue has not been assessed yet.