The memory of local temporary table can only be released when current connection is shutdown
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
In TiDB, if we create a local temporary table, and insert some data into the table, then the memory took up by the temporary table will always be kept, even if we use `truncate` or `delete from temporary_table` to delete all the data in that table. The memory can only be released when current connection is shutdown.
The root cause is when `truncate` or `delete from temporary_table`, TiDB only call `kv.MemBuffer.Delete(key)` to delete the key, but in the implementation of `kv.MemBuffer.Delete(key)`, it actually set a tombstone value to the key instead of delete it. So the memory is not free after `truncate` or `delete from temporary_table`
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
### 2. What did you expect to see? (Required)
### 3. What did you see instead (Required)
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.