Out of Memory

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

Original topic: OOM

| username: 等一分钟

[TiDB Usage Environment] Production Environment
[TiDB Version] 6.1.0
[Reproduction Path] Report export, tidb_server encountered OOM

| username: 等一分钟 | Original post link

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

| username: 等一分钟 | Original post link

The image you provided is not accessible. Please provide the text content you need translated.

| username: 等一分钟 | Original post link

Besides adjusting SQL, are there any other ways to prevent OOM from happening?

| username: 等一分钟 | Original post link

Adding some virtual memory might be effective, but I’m worried that the machine might freeze and become unresponsive.

| username: 等一分钟 | Original post link

Limiting the total memory size of tidb_server has no effect.

| username: xiaoqiao | Original post link

Check if there are any expensive statements in the logs that can be optimized.

| username: zhaokede | Original post link

Is the memory too small?

| username: 等一分钟 | Original post link

32C96G, three TiDB servers
32C64G, three TiKV servers

| username: TIDB-Learner | Original post link

  1. Optimize SQL for batch export.
  2. Configure tidb_mem-quota-query and tidb_mem-quota-concurrency to limit memory usage for individual queries and concurrent operations.
  3. Perform a rolling restart of the TiDB server.
| username: 等一分钟 | Original post link

Is the program connection reset related to TiDB when there is no OOM in TiDB?

| username: DBAER | Original post link

Large SQL can only be split.

| username: 等一分钟 | Original post link

[2024/04/04 03:48:07.837 +08:00] [Error] [terror.go:307] [“encountered error”] [error=“write tcp 10.251.82.17:4000->10.255.11.4:4674: write: connection reset by peer”] [stack="github.com/pingcap/tidb/parser/terror.Log\n\t/home/jenkins/agent/workspace/build-

| username: 等一分钟 | Original post link

What could be the reason for this reset?

| username: ShawnYan | Original post link

I recommend checking this out first,

| username: zhanggame1 | Original post link

The memory is too small, increase it to more than 10G.

| username: YuchongXU | Original post link

Optimize the SQL or increase the memory.

| username: xfworld | Original post link

Upgrading the version provides a better experience in managing OOM issues. At least upgrade to 6.1.7…

If possible, it’s best to upgrade to 6.5.x.

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

It seems that version 6.1.0 does handle OOM issues rather poorly. It is recommended to upgrade to version 6.1.7. If upgrading is not possible at the moment, you can set the tidb_mem_quota_query parameter and use it in conjunction with tidb_mem_oom_action. Alternatively, you can increase the TiFlash replicas for the corresponding large tables in the reports, and try to route report-related queries to TiFlash to prevent excessive memory usage in TiDB.

| username: TiDBer_小阿飞 | Original post link

Shouldn’t this be a network issue?
10.251.82.17:4000->10.255.11.4:4674
Can these two addresses communicate with each other?