TiDB has no SQL execution, so why does it occupy 20G?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb没啥sql执行,为啥就占了20G

| username: TiDBer_h8KizMa7

[TiDB Usage Environment] Production Environment
[TiDB Version] 7.1.0
[Reproduction Path]
[Encountered Problem: Phenomenon and Impact]
When the root user executes SHOW FULL PROCESSLIST, it is found that no SQL is being executed, but the dashboard shows that 20G of memory is already used.
[Resource Configuration]

[Attachment: Screenshot/Log/Monitoring]

| username: tidb菜鸟一只 | Original post link

Uh, with 1 PD, 1 TiDB, and 4 TiKV sharing 30GB of memory, even without running anything, the system processes alone would probably take up around 20GB of memory…

| username: xingzhenxiang | Original post link

It’s already good enough that it can run.

| username: TiDBer_h8KizMa7 | Original post link

Currently, the data volume is relatively small, so it’s being used as a single-machine MySQL. Later, when the data volume increases, it might expand. Using TiDB is convenient for scaling. How can it be optimized?

| username: zhanggame1 | Original post link

Log into the system and use the top command. Press Ctrl+M to sort by memory usage, and you can see the memory usage of each process.

| username: zhanggame1 | Original post link

I also deployed a virtual machine on my computer, and it takes up about 10GB even when it’s not running anything.

| username: TiDBer_h8KizMa7 | Original post link

The image is not visible. Please provide the text content for translation.

| username: TiDBer_h8KizMa7 | Original post link

Yes, it’s terrifying to use up 20G without doing anything. I haven’t even executed a single SQL.

| username: zhanggame1 | Original post link

Memory is all occupied by TiKV.

| username: tidb菜鸟一只 | Original post link

Did you import data into TiKV? It can’t be that you just finished installing it, right?

| username: zhanggame1 | Original post link

I don’t think there’s any problem. Let’s observe for a while.

| username: 有猫万事足 | Original post link

The start times in the Time+ column are all different. It’s impossible that nothing was done, right?

At the very least, there must have been a TiKV restart, right? :sweat_smile:

TiDB has been running longer than PD, so PD most likely restarted as well.

If you just did a tiup cluster start and then did nothing, it shouldn’t be like this.

| username: zhanggame1 | Original post link

select * from INFORMATION_SCHEMA.CLUSTER_CONFIG t where t.KEY like 'storage.block-cache.capacity'

Let’s see what the configuration value is.
Also, check memory-usage-high-water.

| username: TiDBer_h8KizMa7 | Original post link

What I meant by “didn’t do anything” was that I executed SHOW FULL PROCESSLIST as the root user and found that there were no SQL queries being executed. It might be understood differently depending on the role.

| username: TiDBer_h8KizMa7 | Original post link

After running for a period of time, although the load is not high, I recently noticed frequent high memory warnings followed by restarts. Today, after a restart, I observed that the memory usage was already at 20G even without any SQL operations running.

| username: Hacker007 | Original post link

How much data is inside? TiKV sometimes has high memory usage, and it might be that your memory has reached its threshold; otherwise, it could be even more.

| username: TiDBer_h8KizMa7 | Original post link

The official documentation has a detailed description of the monitoring indicators: TiDB 监控框架概述 | PingCAP 文档中心.

| username: TiDBer_h8KizMa7 | Original post link

20GB吧

| username: 有猫万事足 | Original post link

There are several parameters that need to be adjusted for hybrid deployment.

If you haven’t adjusted them, TiKV will assume it is exclusively using the machine. It will use the resources but won’t release them.

I just think your problem might not be about memory not being released, but rather the overall stability of the entire cluster. It might be more serious than you described.

| username: TiDBer_h8KizMa7 | Original post link

Can a hybrid deployment be separated out?