Questions about the tidb_mem_quota_query parameter in TiDB v6.5.0

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

Original topic: tidb-v6.5.0-tidb_mem_quota_query参数疑问

| username: magongyong

[TiDB Usage Environment] Production Environment / Testing / PoC
Testing

[TiDB Version]
6.5.0

[Reproduction Path] What operations were performed when the issue occurred
The cluster was upgraded from 5.4.3 to 6.5.0

[Encountered Issue: Issue Phenomenon and Impact]
The business occasionally reports an Out Of Memory Quota error.

The meaning of the parameter tidb_mem_quota_query has changed significantly compared to before.
I would like to ask if a session is a long connection, for example, running continuously for 10 days, will the memory keep accumulating until tidb_mem_oom_action is triggered?

[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: magongyong | Original post link

May I ask if a session is a long connection, for example, running continuously for 10 days, will the memory keep accumulating until tidb_mem_oom_action is triggered?

| username: magongyong | Original post link

If during these 10 days, the long connection is in a sleep state for some periods, will the memory be automatically released?

| username: 裤衩儿飞上天 | Original post link

This parameter refers to the memory used during the execution of SQL by a single session. Once the SQL execution is completed in a session, the occupied memory can be released. If it is just sleeping, what memory is it occupying? Even the session itself only occupies a very small portion.

| username: magongyong | Original post link

| username: magongyong | Original post link

The meaning of 6.5.0 has changed; it is a session, not a single SQL.

| username: 裤衩儿飞上天 | Original post link

A session can only execute one SQL at a time. To execute the next one, you have to wait for the previous one to finish.

| username: magongyong | Original post link

Do you consider 10 SQL statements executed serially in the same thread as one session or multiple sessions?

| username: 裤衩儿飞上天 | Original post link

One…

| username: magongyong | Original post link

Yes, so if this session continues to execute multiple SQL statements intermittently, will it keep accumulating memory? This is my point of concern. Based on our current test observations, it does accumulate, but it is unclear when the memory will be released.

| username: 裤衩儿飞上天 | Original post link

After executing a query, the occupied memory should be released. Even if the cache is not immediately cleared, it can be reused. If the situation you measured is indeed accumulating without releasing, then there must be a bug.

| username: magongyong | Original post link

It’s hard to say. There were no errors reported before the upgrade, but after the upgrade, quite a few OOMs were triggered.

| username: 特雷西-迈克-格雷迪 | Original post link

You can check it on the dashboard.

| username: wzf0072 | Original post link

Changes in the execution plan can lead to different memory usage. You can try using ANALYZE TABLE.

| username: 裤衩儿飞上天 | Original post link

With version 6.5, global memory control has greatly improved the OOM situation. For the specific reasons why the system encounters OOM, you can start a new thread and post the relevant logs so that the experts can take a look and determine the cause.

| username: magongyong | Original post link

Thank you, I have found the cause. It is due to the tidb_server_memory_limit parameter, which was introduced in version 6.4.0 and defaults to 2GB. With many connections and a larger SQL query, it reports “Out Of Memory Quota.”

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.