How to Determine OOM When TiDB Server Executes SQL?

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

Original topic: tidb server执行SQL,如何判断OOM?

| username: yytest

How to determine OOM (Out of Memory) when TiDB server executes SQL?

| username: TiDBer_小阿飞 | Original post link

| username: DBAER | Original post link

If it’s just SQL, there is a parameter tidb_mem_quota_query to control the memory size for SQL.

| username: TiDBer_QYr0vohO | Original post link

Check the memory consumption of the SQL query, and also the parameter tidb_mem_quota_query.

| username: zhaokede | Original post link

You can check the system logs and monitor system metrics to see if there is an OOM (Out of Memory) issue.

| username: 健康的腰间盘 | Original post link

If testing, try setting the tidb_mem_quota_query limit smaller to see what the OOM result is.

| username: tony5413 | Original post link

Check logs and monitor.

| username: Kamner | Original post link

When an OOM (Out of Memory) occurs, the session is usually forcibly interrupted. Both the TiDB server and the TiKV server may experience OOM.

Check the operating system logs:
dmesg -T | grep tidb-server
dmesg -T | grep tikv-server

| username: juecong | Original post link

The most straightforward way is to write a large SQL query in the test environment and set the parameter tidb_mem_quota_query to a few MB, then you can reproduce it.

| username: TIDB-Learner | Original post link

Read the documentation whenever you have free time.

| username: Jack-li | Original post link

“Check error logs,” “Set memory thresholds and behavior”

| username: 小于同学 | Original post link

Try modifying the tidb_mem_quota_query parameter to reproduce the issue.