From 2d85d2a76b569874a330345413c3229a5d37e0e3 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Fri, 22 May 2026 15:58:24 +0800 Subject: [PATCH 01/12] tidb: global memory arbitrator mechanism (#22882) --- configure-memory-usage.md | 144 +++++++++++++++++++++++++++++++++++++- system-variables.md | 64 +++++++++++++++++ 2 files changed, 206 insertions(+), 2 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 3e0f62257ef66..61c02e15c49bd 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -207,8 +207,6 @@ The following example uses a memory-consuming SQL statement to demonstrate the d 9 rows in set (1 min 37.428 sec) ``` -## Others - ### Mitigate OOM issues by configuring `GOMEMLIMIT` GO 1.19 introduces an environment variable [`GOMEMLIMIT`](https://pkg.go.dev/runtime@go1.19#hdr-Environment_Variables) to set the memory limit that triggers GC. @@ -226,3 +224,145 @@ To verify the performance of `GOMEMLIMIT`, a test is performed to compare the sp - In TiDB v6.1.3, `GOMEMLIMIT` is set to 40000 MiB. It is found that the simulated workload runs stably for a long time, OOM does not occur in the TiDB server, and the maximum memory usage of the process is stable at around 40.8 GiB: ![v6.1.3 workload no oom with GOMEMLIMIT](/media/configure-memory-usage-613-no-oom.png) + +## Memory arbitrator mode + +Before TiDB v9.0.0, the [memory control mechanism](#configure-the-memory-usage-threshold-of-a-tidb-server-instance) has the following issues: + +- When the memory usage of a TiDB instance exceeds the limit, TiDB might randomly terminate running SQL statements. +- Memory resources follow a "use first and report later" mechanism, and memory usage is isolated across different SQL statements. As a result, TiDB cannot centrally schedule or control memory resources at the instance level. +- Under high memory pressure, the overhead of Go garbage collection (GC) increases significantly, and in severe cases might cause out of memory (OOM) issues. + +Starting from v9.0.0, TiDB introduces memory arbitrator mode. This mode introduces a global memory arbitrator in each TiDB instance to centrally manage and schedule the memory resources of the instance from top to bottom, mitigating the preceding issues. + +> **Warning:** +> +> This feature is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you find a bug, report it by submitting an [issue](https://github.com/pingcap/tidb/issues) on GitHub. + +You can enable memory arbitrator mode using the [`tidb_mem_arbitrator_mode`](/system-variables.md#tidb_mem_arbitrator_mode-new-in-v900) system variable or the `instance.tidb_mem_arbitrator_mode` parameter in the TiDB configuration file. + +- `disable`: disables memory arbitrator mode + +- `standard` or `priority`: enables memory arbitrator mode. After it is enabled: + - Memory resources are used with a subscribe-before-allocation mechanism and are uniformly scheduled by the memory arbitrator in each TiDB instance. + - The overall memory usage of the TiDB instance is expected not to exceed the limit of [`tidb_server_memory_limit`](/system-variables.md#tidb_server_memory_limit-new-in-v640), and the [alarm for high memory usage](#trigger-the-alarm-of-excessive-memory-usage) no longer takes effect. + - The behavior of the following system variables remains effective: + - [`tidb_mem_oom_action`](/system-variables.md#tidb_mem_oom_action-new-in-v610) + - [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) + - [`max_execution_time`](/system-variables.md#max_execution_time) + +When memory resources are insufficient or there is an OOM risk, the arbitrator can reclaim memory resources by terminating SQL statements, but it does not terminate `DDL`, `DCL`, or `TCL` SQL statements. Terminated SQL returns error code `8180` to the client. The error format is: `Query execution was stopped by the global memory arbitrator [reason=?, path=?] [conn=?]`. The related fields are explained as follows: + +- `conn`: the connection (session) ID +- `reason`: the specific reason why the SQL is terminated +- `path`: the stage at which the SQL is terminated (if the error does not contain the `path` field, the SQL is terminated during the execution stage) + - `ParseSQL`: parsing + - `CompilePlan`: compiling the execution plan + +Memory arbitrator mode pools the arbitrable memory resources in each TiDB instance. The memory resources corresponding to `tidb_server_memory_limit` are divided into the following four categories, which can be viewed through the `Mem Quota Stats` monitoring metric: + +- `allocated`: allocated memory quota, including but not limited to the memory pool to which the SQL belongs and the memory pools of various public modules +- `available`: allocatable memory quota +- `buffer`: memory quota of the buffer +- `out-of-control`: memory quota not controlled by the arbitrator, including but not limited to: + - unsafe or disabled memory + - memory waiting for garbage collection + - memory used by the Go runtime + - other untracked memory usage + +`out-of-control` is a risk metric that requires special attention. It is dynamically calculated by the arbitrator, with a minimum value of `tidb_server_memory_limit - tidb_mem_arbitrator_soft_limit`. The arbitrator quantifies this type of risky memory quota as accurately as possible and reserves space for it during memory allocation, thereby reducing the risk of OOM in the TiDB instance. + +### `standard` mode + +In `standard` mode, during SQL execution, SQL dynamically subscribes to memory resources from the arbitrator and blocks to wait when resources are insufficient. The arbitrator processes subscription requests on a first in, first out (FIFO) basis. + +- When parsing SQL or compiling the execution plan, the required memory quota is estimated by TiDB and is proportional to the number of SQL keywords. +- If global memory resources are insufficient, the arbitrator fails the subscription request and terminates the SQL. The `reason` field in the returned error is `CANCEL(out-of-quota & standard-mode)`. + +### `priority` mode + +In `priority` mode, during SQL execution, SQL dynamically subscribes to memory resources from the arbitrator and blocks to wait when resources are insufficient. The arbitrator processes subscription requests according to the [resource group priority](/information-schema/information-schema-resource-groups.md) (`LOW | MEDIUM | HIGH`) to which the SQL belongs. + +- When parsing SQL or compiling the execution plan, the required memory quota is estimated by TiDB and is proportional to the number of SQL keywords. Unlike `standard` mode, in `priority` mode, unless there is an `OOM` risk, a failed subscription does not immediately terminate the SQL. +- The arbitrator processes subscription requests in descending order of priority. Requests with the same priority are queued in the order they are initiated. +- When global memory resources are insufficient: + - The arbitrator terminates lower-priority SQL in order (from low to high priority, and from large to small memory quota usage) to reclaim resources for higher-priority SQL. The `reason` field in the returned error is `CANCEL(out-of-quota & priority-mode)`. + - If there is no terminable SQL, the subscription request continues to wait until an existing SQL finishes execution and releases resources. + +If you want SQL to avoid the latency overhead caused by waiting for memory resources, you can set the [`tidb_mem_arbitrator_wait_averse`](/system-variables.md#tidb_mem_arbitrator_wait_averse-new-in-v900) system variable to `1`. + +- The subscription requests of the related SQL are automatically bound to priority `HIGH`. +- When global memory resources are insufficient, the arbitrator directly terminates the related SQL, and the `reason` field in the returned error is `CANCEL(out-of-quota & wait-averse)`. + +### Memory risk control + +When the memory usage of a TiDB instance reaches the `95%` threshold of `tidb_server_memory_limit`, the arbitrator starts handling memory risks. If the actual memory usage cannot be reduced to a safe level in the short term or the actual memory release rate is too low, the TiDB instance faces the `OOM` risk. The arbitrator forcibly terminates SQL in order (from low to high priority, and from large to small memory quota usage), and the `reason` field in the returned error is `KILL(out-of-memory)`. + +If you need to force SQL to run when memory resources are insufficient, you can set the [`tidb_mem_arbitrator_wait_averse`](/system-variables.md#tidb_mem_arbitrator_wait_averse-new-in-v900) system variable to `nolimit`. This variable makes the memory usage of the related SQL unrestricted by the arbitrator, but it might cause the TiDB instance to `OOM`. + +### Manually ensuring memory safety + +You can set the upper limit of the arbitrator's memory quota in a TiDB instance using the [`tidb_mem_arbitrator_soft_limit`](/system-variables.md#tidb_mem_arbitrator_soft_limit-new-in-v900) system variable or the `instance.tidb_mem_arbitrator_soft_limit` parameter in the TiDB configuration file. The smaller the upper limit, the safer the global memory, but the lower the memory resource utilization. You can use this variable to manually and quickly converge memory risks. + +TiDB internally caches the historical maximum memory usage of some SQL statements and pre-subscribes sufficient memory quota before the next execution of the SQL. If it is known that a SQL statement has a large amount of uncontrolled memory usage, you can use the [`tidb_mem_arbitrator_query_reserved`](/system-variables.md#tidb_mem_arbitrator_query_reserved-new-in-v900) system variable to specify the quota subscribed by the SQL. The larger the value, the safer the global memory, but the lower the memory resource utilization. Pre-subscribing sufficient or excess quota can effectively ensure the isolation of memory resources for SQL. + +### Monitoring and observability metrics + +The `TiDB / Memory Arbitrator` panel is added to `Grafana` monitoring, containing the following metrics: + +- `Work Mode`: the memory management mode of the TiDB instance +- `Arbitration Exec`: statistics on the arbitrator processing various requests +- `Events`: statistics on various events in arbitrator mode. Pay special attention to `mem-risk` (memory risk) and `oom-risk` (`OOM` risk) +- `Mem Quota Stats`: usage of various memory quotas. Pay special attention to `out-of-control`, `wait-alloc` (total memory quota waiting for allocation), and `mem-inuse` (actual memory usage) +- `Mem Quota Arbitration`: processing time of memory resource subscription requests +- `Mem Pool Stats`: the number of various memory pools +- `Runtime Mem Pressure`: memory pressure value, that is, the ratio of actual memory usage to allocated memory quota +- `Waiting Tasks`: the number of various tasks queued and waiting for memory allocation + +[`SLOW_QUERY`](/information-schema/information-schema-slow-query.md) adds the `Mem_arbitration` field, which indicates the total time that SQL waits for memory resources. The `Mem Arbitration` column on the [TiDB Dashboard slow query page](/dashboard/dashboard-slow-query.md) also displays this information. + +[`PROCESSLIST`](/information-schema/information-schema-processlist.md) adds the following fields: + +- `MEM_ARBITRATION`: the total time that SQL has waited for memory resources so far +- `MEM_WAIT_ARBITRATE_START`: the start time of the current memory resource subscription request. If there is currently no waiting subscription request, the value is NULL +- `MEM_WAIT_ARBITRATE_BYTES`: the requested bytes of the current memory resource subscription request. If there is currently no waiting subscription request, the value is NULL + +[`Expensive query`](/identify-expensive-queries.md) adds the `mem_arbitration` field to record the time that SQL waits for memory resources and the information of the current subscription request, for example: + +- `cost_time 2.1s, wait_start 1970-01-02 10:17:36.789 UTC, wait_bytes 123456789123 Bytes (115.0 GB)` + +[`STATEMENTS_SUMMARY`](/statement-summary-tables.md): the `statements_summary`, `statements_summary_history`, `cluster_statements_summary`, and `cluster_statements_summary_history` tables add the following fields. The `Mean Mem Arbitration` column on the [TiDB Dashboard SQL statement analysis execution details page](/dashboard/dashboard-statement-list.md) also displays this information: + +- `AVG_MEM_ARBITRATION`: the average time that SQL waits for memory resources +- `MAX_MEM_ARBITRATION`: the maximum time that SQL waits for memory resources + +### Best practices + +The default value `80%` of the `tidb_server_memory_limit` system variable is relatively small. After enabling memory arbitrator mode, it is recommended to set it to `95%`. + +In single-node TiDB deployment scenarios: + +- If `priority` mode is enabled, it is recommended to bind OLTP-related SQL or business-critical SQL to high-priority resource groups, and bind other SQL to medium-priority or low-priority resource groups as needed +- If `standard` mode is enabled and SQL returns error `8180`, it is recommended to retry the SQL after waiting for a period of time + +In multi-node TiDB deployment scenarios: + +- If `standard` mode is enabled and SQL returns error `8180`, it is recommended to retry the SQL on another TiDB node. + +- If `priority` mode is enabled: + - It is recommended to bind OLTP-related SQL or business-critical SQL to high-priority resource groups, and bind other SQL to medium-priority or low-priority resource groups as needed. + - Use `max_execution_time` to limit the maximum execution time of SQL. + - If a timeout or error `8180` occurs, it is recommended to retry the SQL on another TiDB node. + - If you want SQL to fail quickly when memory resources are insufficient and then be retried on another node, you can set `tidb_mem_arbitrator_wait_averse`. + +- TiDB instance grouping + - In each group, use the `instance.tidb_mem_arbitrator_mode` parameter in the configuration file to set the memory management mode of TiDB instances. + - In each group, use the `instance.tidb_mem_arbitrator_soft_limit` parameter in the configuration file to set the upper limit of the memory quota of TiDB instances as needed. + - Distribute SQL to different instance groups according to business requirements, and handle SQL failures or retries based on the arbitrator mode of each instance group. + +You can take the following measures to ensure the execution of important SQL: + +- Use `tidb_mem_arbitrator_query_reserved` to pre-subscribe memory quota for important SQL, enhancing its memory resource isolation. +- Bind important SQL to high-priority resource groups. +- Set `tidb_mem_quota_query` to a larger value to reduce the probability that a single SQL is interrupted because it exceeds the memory quota. +- If you can accept the OOM risk, set `tidb_mem_arbitrator_wait_averse` to `nolimit` so that the related SQL bypasses the memory arbitrator limitation. diff --git a/system-variables.md b/system-variables.md index 9955004ead6a0..62aa01995463b 100644 --- a/system-variables.md +++ b/system-variables.md @@ -3995,6 +3995,70 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - Unit: Threads - This variable is used to set the maximum concurrency for TiFlash to execute a request. The default value is `-1`, indicating that this system variable is invalid and the maximum concurrency depends on the setting of the TiFlash configuration `profiles.default.max_threads`. When the value is `0`, the maximum number of threads is automatically configured by TiFlash. +### tidb_mem_arbitrator_mode New in v9.0.0 + +> **Warning:** +> +> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. + +- Scope: GLOBAL +- Persists to cluster: Yes +- Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No +- Type: Enum +- Default value: `disable` +- Possible values: `disable`, `standard`, `priority` +- This variable sets the memory management mode of a TiDB instance. For more information, see [TiDB memory control](/configure-memory-usage.md#memory-arbitrator-mode). The following values are supported: + - `disable` (default): Disables memory arbitrator mode and keeps the mechanism of [use first and report later](/system-variables.md#tidb_server_memory_limit-new-in-v640). + - `standard`: Enables standard memory arbitrator mode. When SQL needs to use memory resources, it first subscribes to the memory arbitrator and allocates memory resources only after the subscription succeeds. If the subscription fails, the SQL execution is terminated. + - `priority`: Enables priority-based memory arbitrator mode. When SQL needs to use memory resources, it first subscribes to the memory arbitrator and allocates memory resources only after the subscription succeeds. TiDB handles memory resource subscription requests according to the SQL [resource group priority](/information-schema/information-schema-resource-groups.md). + +### tidb_mem_arbitrator_query_reserved New in v9.0.0 + +> **Warning:** +> +> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. + +- Scope: SESSION +- Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes +- Type: Integer +- Default value: `0` +- Unit: Bytes +- Range: `[0, 9223372036854775807]` +- When [memory arbitrator mode](/configure-memory-usage.md#memory-arbitrator-mode) is enabled, this variable controls the amount of memory resources that SQL pre-subscribes to from the memory arbitrator before execution. For more information, see [TiDB memory control](/configure-memory-usage.md#manually-ensuring-memory-safety). + +### tidb_mem_arbitrator_soft_limit New in v9.0.0 + +> **Warning:** +> +> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. + +- Scope: GLOBAL +- Persists to cluster: Yes +- Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No +- Type: String +- Default value: `0` +- Possible values: `0`, floating-point number `(0, 1]`, integer `(1, 9223372036854775807]` +- When [memory arbitrator mode](/configure-memory-usage.md#memory-arbitrator-mode) is enabled, this variable controls the upper limit of memory resources that the arbitrator can allocate in a TiDB instance. For more information, see [TiDB memory control](/configure-memory-usage.md#manually-ensuring-memory-safety). + - `0`: The default upper limit of memory resources is `95%` of the value of [`tidb_server_memory_limit`](/system-variables.md#tidb_server_memory_limit-new-in-v640). + - Floating-point number `(0, 1]`: Specifies the upper limit of memory resources as a ratio relative to [`tidb_server_memory_limit`](/system-variables.md#tidb_server_memory_limit-new-in-v640). For example, `0.8` means the upper limit of memory resources is `tidb_server_memory_limit * 0.8`. + - Integer `(1, 9223372036854775807]`: Specifies the number of bytes. + +### tidb_mem_arbitrator_wait_averse New in v9.0.0 + +> **Warning:** +> +> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. + +- Scope: SESSION +- Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No +- Type: Enum +- Default value: `0` +- Possible values: `0`, `1`, `nolimit` +- When [memory arbitrator mode](/configure-memory-usage.md#memory-arbitrator-mode) is enabled, this variable controls the behavior of SQL when waiting for memory resources. For more information, see [TiDB memory control](/configure-memory-usage.md#memory-arbitrator-mode). + - `0` (default): Disables this feature, and the variable does not take effect. + - `1`: Takes effect only in `priority` mode. SQL is automatically bound to high priority when subscribing to memory resources. When global memory resources are insufficient, the SQL execution is terminated instead of being blocked waiting. + - `nolimit`: The memory usage of SQL is not limited by the arbitrator. This value might increase the risk of OOM on the TiDB instance. + ### tidb_mem_oom_action New in v6.1.0 - Scope: GLOBAL From f9e2ec878a096122b99aa0b8b3dd6ce6c127d7c7 Mon Sep 17 00:00:00 2001 From: qiancai Date: Mon, 2 Nov 2026 14:27:36 +0800 Subject: [PATCH 02/12] v9.0.0 -> CLOUD.202609.1 --- configure-memory-usage.md | 4 ++-- system-variables.md | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 61c02e15c49bd..568ed4fa228d4 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -227,13 +227,13 @@ To verify the performance of `GOMEMLIMIT`, a test is performed to compare the sp ## Memory arbitrator mode -Before TiDB v9.0.0, the [memory control mechanism](#configure-the-memory-usage-threshold-of-a-tidb-server-instance) has the following issues: +Before CLOUD.202609.1, the [memory control mechanism](#configure-the-memory-usage-threshold-of-a-tidb-server-instance) has the following issues: - When the memory usage of a TiDB instance exceeds the limit, TiDB might randomly terminate running SQL statements. - Memory resources follow a "use first and report later" mechanism, and memory usage is isolated across different SQL statements. As a result, TiDB cannot centrally schedule or control memory resources at the instance level. - Under high memory pressure, the overhead of Go garbage collection (GC) increases significantly, and in severe cases might cause out of memory (OOM) issues. -Starting from v9.0.0, TiDB introduces memory arbitrator mode. This mode introduces a global memory arbitrator in each TiDB instance to centrally manage and schedule the memory resources of the instance from top to bottom, mitigating the preceding issues. +Starting from CLOUD.202609.1, TiDB introduces memory arbitrator mode. This mode introduces a global memory arbitrator in each TiDB instance to centrally manage and schedule the memory resources of the instance from top to bottom, mitigating the preceding issues. > **Warning:** > diff --git a/system-variables.md b/system-variables.md index 62aa01995463b..2d122427a657d 100644 --- a/system-variables.md +++ b/system-variables.md @@ -3995,7 +3995,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - Unit: Threads - This variable is used to set the maximum concurrency for TiFlash to execute a request. The default value is `-1`, indicating that this system variable is invalid and the maximum concurrency depends on the setting of the TiFlash configuration `profiles.default.max_threads`. When the value is `0`, the maximum number of threads is automatically configured by TiFlash. -### tidb_mem_arbitrator_mode New in v9.0.0 +### tidb_mem_arbitrator_mode New in CLOUD.202609.1 > **Warning:** > @@ -4012,7 +4012,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - `standard`: Enables standard memory arbitrator mode. When SQL needs to use memory resources, it first subscribes to the memory arbitrator and allocates memory resources only after the subscription succeeds. If the subscription fails, the SQL execution is terminated. - `priority`: Enables priority-based memory arbitrator mode. When SQL needs to use memory resources, it first subscribes to the memory arbitrator and allocates memory resources only after the subscription succeeds. TiDB handles memory resource subscription requests according to the SQL [resource group priority](/information-schema/information-schema-resource-groups.md). -### tidb_mem_arbitrator_query_reserved New in v9.0.0 +### tidb_mem_arbitrator_query_reserved New in CLOUD.202609.1 > **Warning:** > @@ -4026,7 +4026,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - Range: `[0, 9223372036854775807]` - When [memory arbitrator mode](/configure-memory-usage.md#memory-arbitrator-mode) is enabled, this variable controls the amount of memory resources that SQL pre-subscribes to from the memory arbitrator before execution. For more information, see [TiDB memory control](/configure-memory-usage.md#manually-ensuring-memory-safety). -### tidb_mem_arbitrator_soft_limit New in v9.0.0 +### tidb_mem_arbitrator_soft_limit New in CLOUD.202609.1 > **Warning:** > @@ -4043,7 +4043,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - Floating-point number `(0, 1]`: Specifies the upper limit of memory resources as a ratio relative to [`tidb_server_memory_limit`](/system-variables.md#tidb_server_memory_limit-new-in-v640). For example, `0.8` means the upper limit of memory resources is `tidb_server_memory_limit * 0.8`. - Integer `(1, 9223372036854775807]`: Specifies the number of bytes. -### tidb_mem_arbitrator_wait_averse New in v9.0.0 +### tidb_mem_arbitrator_wait_averse New in CLOUD.202609.1 > **Warning:** > From 678908876c412d0e4699068950f0a37489c9f6c7 Mon Sep 17 00:00:00 2001 From: qiancai Date: Mon, 2 Nov 2026 14:36:03 +0800 Subject: [PATCH 03/12] add custom content for 2609 changes --- configure-memory-usage.md | 10 +++++++++- system-variables.md | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 568ed4fa228d4..c1f486f99d174 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -70,6 +70,8 @@ To view the memory usage of the current instance or cluster, you can query the s To view the memory-related operations and execution basis of the current instance or cluster, you can query the system table [`INFORMATION_SCHEMA.(CLUSTER_)MEMORY_USAGE_OPS_HISTORY`](/information-schema/information-schema-memory-usage-ops-history.md). For each instance, this table retains the latest 50 records. + + ## Trigger the alarm of excessive memory usage When the memory usage of a tidb-server instance exceeds its memory threshold (70% of its total memory by default) and any of the following conditions is met, TiDB records the related status files and prints an alarm log. @@ -129,6 +131,8 @@ The following example constructs a memory-intensive SQL statement that triggers 5. By checking the directory of status files (In the preceding example, the directory is `/tiup/deploy/tidb-4000/log/oom_record`), you can see a record directory with the corresponding timestamp (for example, `record2022-10-09T17:18:38+08:00`). The record directory includes three files: `goroutinue`, `heap`, and `running_sql`. These three files are suffixed with the time when status files are logged. They respectively record goroutine stack information, the usage status of heap memory, and the running SQL information when the alarm is triggered. For the content in `running_sql`, refer to [`expensive-queries`](/identify-expensive-queries.md). + + ## Reduce the memory usage for write transactions in tidb-server The transaction model used by TiDB requires that all write operations of transactions are first cached in memory before being committed. When TiDB writes large transactions, memory usage might increase and become a bottleneck. To reduce or avoid high memory usage by large transactions under various constraints, you can adjust the [`tidb_dml_type`](/system-variables.md#tidb_dml_type-new-in-v800) system variable to `"bulk"` or use [Non-transactional DML statements](/non-transactional-dml.md). @@ -150,7 +154,7 @@ TiDB supports disk spill for execution operators. When the memory usage of a SQL - When the disk spill is triggered, TiDB outputs a log containing the keywords `memory exceeds quota, spill to disk now` or `memory exceeds quota, set aggregate mode to spill-mode`. - Disk spill for the Sort, MergeJoin, and HashJoin operators is introduced in v4.0.0. Disk spill for the non-parallel algorithm of the HashAgg operator is introduced in v5.2.0. Disk spill for the parallel algorithm of the HashAgg operator is introduced in v8.0.0 as an experimental feature and becomes generally available (GA) in v8.2.0. Disk spill for the TopN operator is introduced in v8.3.0. - You can control whether to enable the parallel HashAgg algorithm that supports disk spill using the [`tidb_enable_parallel_hashagg_spill`](/system-variables.md#tidb_enable_parallel_hashagg_spill-new-in-v800) system variable. This variable will be deprecated in a future release. -- When the SQL executions containing Sort, MergeJoin, HashJoin, HashAgg, or TopN cause OOM, TiDB triggers disk spill by default. +- When the SQL executions containing Sort, MergeJoin, HashJoin, HashAgg, or TopN cause OOM, TiDB triggers disk spill by default. > **Note:** > @@ -225,6 +229,8 @@ To verify the performance of `GOMEMLIMIT`, a test is performed to compare the sp ![v6.1.3 workload no oom with GOMEMLIMIT](/media/configure-memory-usage-613-no-oom.png) + + ## Memory arbitrator mode Before CLOUD.202609.1, the [memory control mechanism](#configure-the-memory-usage-threshold-of-a-tidb-server-instance) has the following issues: @@ -366,3 +372,5 @@ You can take the following measures to ensure the execution of important SQL: - Bind important SQL to high-priority resource groups. - Set `tidb_mem_quota_query` to a larger value to reduce the probability that a single SQL is interrupted because it exceeds the memory quota. - If you can accept the OOM risk, set `tidb_mem_arbitrator_wait_averse` to `nolimit` so that the related SQL bypasses the memory arbitrator limitation. + + \ No newline at end of file diff --git a/system-variables.md b/system-variables.md index 2d122427a657d..30628843b6a3e 100644 --- a/system-variables.md +++ b/system-variables.md @@ -3995,6 +3995,8 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - Unit: Threads - This variable is used to set the maximum concurrency for TiFlash to execute a request. The default value is `-1`, indicating that this system variable is invalid and the maximum concurrency depends on the setting of the TiFlash configuration `profiles.default.max_threads`. When the value is `0`, the maximum number of threads is automatically configured by TiFlash. + + ### tidb_mem_arbitrator_mode New in CLOUD.202609.1 > **Warning:** @@ -4059,6 +4061,8 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - `1`: Takes effect only in `priority` mode. SQL is automatically bound to high priority when subscribing to memory resources. When global memory resources are insufficient, the SQL execution is terminated instead of being blocked waiting. - `nolimit`: The memory usage of SQL is not limited by the arbitrator. This value might increase the risk of OOM on the TiDB instance. + + ### tidb_mem_oom_action New in v6.1.0 - Scope: GLOBAL From 0a22583a8d71d603d48545ed1db72f1f2c3dbf2b Mon Sep 17 00:00:00 2001 From: qiancai Date: Mon, 2 Nov 2026 15:07:59 +0800 Subject: [PATCH 04/12] add CustomContent for tidb_mem_oom_action --- configure-memory-usage.md | 18 +++++++++++++++--- system-variables.md | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index c1f486f99d174..01119d9edc86b 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -5,11 +5,23 @@ summary: Learn how to configure the memory quota of a query and avoid OOM (out o # TiDB Memory Control -Currently, TiDB can track the memory quota of a single SQL query and take actions to prevent OOM (out of memory) or troubleshoot OOM when the memory usage exceeds a specific threshold value. The system variable [`tidb_mem_oom_action`](/system-variables.md#tidb_mem_oom_action-new-in-v610) specifies the action to take when a query reaches the memory limit: +Currently, TiDB can track the memory quota of a single SQL query and take actions to prevent OOM (out of memory) or troubleshoot OOM when the memory usage exceeds a specific threshold value. + + + +The system variable [`tidb_mem_oom_action`](/system-variables.md#tidb_mem_oom_action-new-in-v610) specifies the action to take when a query reaches the memory limit: - A value of `LOG` means that queries will continue to execute when the [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) limit is reached, but TiDB will print an entry to the log. - A value of `CANCEL` means TiDB stops executing the SQL query immediately after the [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) limit is reached, and returns an error to the client. The error information clearly shows the memory usage of each physical execution operator that consumes memory in the SQL execution process. + + + + +When a single SQL statement exceeds the memory quota specified by [`tidb_mem_quota_query`](#tidb_mem_quota_query), TiDB Cloud stops executing the SQL query immediately and returns an error to the client. The error information clearly shows the memory usage of each physical execution operator that consumes memory in the SQL execution process. + + + ## Configure the memory quota of a query The system variable [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) sets the limit for a query in bytes. Some usage examples: @@ -131,8 +143,6 @@ The following example constructs a memory-intensive SQL statement that triggers 5. By checking the directory of status files (In the preceding example, the directory is `/tiup/deploy/tidb-4000/log/oom_record`), you can see a record directory with the corresponding timestamp (for example, `record2022-10-09T17:18:38+08:00`). The record directory includes three files: `goroutinue`, `heap`, and `running_sql`. These three files are suffixed with the time when status files are logged. They respectively record goroutine stack information, the usage status of heap memory, and the running SQL information when the alarm is triggered. For the content in `running_sql`, refer to [`expensive-queries`](/identify-expensive-queries.md). - - ## Reduce the memory usage for write transactions in tidb-server The transaction model used by TiDB requires that all write operations of transactions are first cached in memory before being committed. When TiDB writes large transactions, memory usage might increase and become a bottleneck. To reduce or avoid high memory usage by large transactions under various constraints, you can adjust the [`tidb_dml_type`](/system-variables.md#tidb_dml_type-new-in-v800) system variable to `"bulk"` or use [Non-transactional DML statements](/non-transactional-dml.md). @@ -229,6 +239,8 @@ To verify the performance of `GOMEMLIMIT`, a test is performed to compare the sp ![v6.1.3 workload no oom with GOMEMLIMIT](/media/configure-memory-usage-613-no-oom.png) + + ## Memory arbitrator mode diff --git a/system-variables.md b/system-variables.md index 30628843b6a3e..07f6096fd9318 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4065,6 +4065,10 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified ### tidb_mem_oom_action New in v6.1.0 +> **Note:** +> +> This variable is read-only for TiDB Cloud Starter, TiDB Cloud Essential, TiDB Cloud Premium, and TiDB Cloud BYOC instances. + - Scope: GLOBAL - Persists to cluster: Yes - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No From cd11b7ea9f3a00f80d25dff6d01894b40920355a Mon Sep 17 00:00:00 2001 From: Zhigao TONG Date: Mon, 30 Nov 2026 17:24:28 +0800 Subject: [PATCH 05/12] Apply batched suggestions from code review Co-authored-by: Zhigao TONG --- system-variables.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/system-variables.md b/system-variables.md index 07f6096fd9318..81a6fdb6318cc 100644 --- a/system-variables.md +++ b/system-variables.md @@ -3999,9 +3999,9 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified ### tidb_mem_arbitrator_mode New in CLOUD.202609.1 -> **Warning:** +> **Note:** > -> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. +> This variable is read-only for TiDB Cloud Starter and TiDB Cloud Essential instances. - Scope: GLOBAL - Persists to cluster: Yes @@ -4016,9 +4016,9 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified ### tidb_mem_arbitrator_query_reserved New in CLOUD.202609.1 -> **Warning:** +> **Note:** > -> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. +> This variable is read-only for TiDB Cloud Starter and TiDB Cloud Essential instances. - Scope: SESSION - Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes @@ -4030,9 +4030,9 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified ### tidb_mem_arbitrator_soft_limit New in CLOUD.202609.1 -> **Warning:** +> **Note:** > -> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. +> This variable is read-only for TiDB Cloud Starter and TiDB Cloud Essential instances. - Scope: GLOBAL - Persists to cluster: Yes @@ -4047,9 +4047,9 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified ### tidb_mem_arbitrator_wait_averse New in CLOUD.202609.1 -> **Warning:** +> **Note:** > -> The feature controlled by this variable is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you encounter any bugs, report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. +> This variable is read-only for TiDB Cloud Starter and TiDB Cloud Essential instances. - Scope: SESSION - Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No From e00d6602521213859fb511d68914a92984a8c9fe Mon Sep 17 00:00:00 2001 From: Zhigao TONG Date: Mon, 30 Nov 2026 17:32:51 +0800 Subject: [PATCH 06/12] Update configure-memory-usage.md --- configure-memory-usage.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 01119d9edc86b..2b12a5c2d8148 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -356,8 +356,6 @@ The `TiDB / Memory Arbitrator` panel is added to `Grafana` monitoring, containin ### Best practices -The default value `80%` of the `tidb_server_memory_limit` system variable is relatively small. After enabling memory arbitrator mode, it is recommended to set it to `95%`. - In single-node TiDB deployment scenarios: - If `priority` mode is enabled, it is recommended to bind OLTP-related SQL or business-critical SQL to high-priority resource groups, and bind other SQL to medium-priority or low-priority resource groups as needed @@ -383,6 +381,5 @@ You can take the following measures to ensure the execution of important SQL: - Use `tidb_mem_arbitrator_query_reserved` to pre-subscribe memory quota for important SQL, enhancing its memory resource isolation. - Bind important SQL to high-priority resource groups. - Set `tidb_mem_quota_query` to a larger value to reduce the probability that a single SQL is interrupted because it exceeds the memory quota. -- If you can accept the OOM risk, set `tidb_mem_arbitrator_wait_averse` to `nolimit` so that the related SQL bypasses the memory arbitrator limitation. - \ No newline at end of file + From 4b72c6183e029c483e2f3b22478bcc461c7c1eb8 Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Tue, 1 Dec 2026 17:49:53 +0800 Subject: [PATCH 07/12] remove best practices from Memory arbitrator mode --- configure-memory-usage.md | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 2b12a5c2d8148..7825a9f9720a4 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -354,32 +354,4 @@ The `TiDB / Memory Arbitrator` panel is added to `Grafana` monitoring, containin - `AVG_MEM_ARBITRATION`: the average time that SQL waits for memory resources - `MAX_MEM_ARBITRATION`: the maximum time that SQL waits for memory resources -### Best practices - -In single-node TiDB deployment scenarios: - -- If `priority` mode is enabled, it is recommended to bind OLTP-related SQL or business-critical SQL to high-priority resource groups, and bind other SQL to medium-priority or low-priority resource groups as needed -- If `standard` mode is enabled and SQL returns error `8180`, it is recommended to retry the SQL after waiting for a period of time - -In multi-node TiDB deployment scenarios: - -- If `standard` mode is enabled and SQL returns error `8180`, it is recommended to retry the SQL on another TiDB node. - -- If `priority` mode is enabled: - - It is recommended to bind OLTP-related SQL or business-critical SQL to high-priority resource groups, and bind other SQL to medium-priority or low-priority resource groups as needed. - - Use `max_execution_time` to limit the maximum execution time of SQL. - - If a timeout or error `8180` occurs, it is recommended to retry the SQL on another TiDB node. - - If you want SQL to fail quickly when memory resources are insufficient and then be retried on another node, you can set `tidb_mem_arbitrator_wait_averse`. - -- TiDB instance grouping - - In each group, use the `instance.tidb_mem_arbitrator_mode` parameter in the configuration file to set the memory management mode of TiDB instances. - - In each group, use the `instance.tidb_mem_arbitrator_soft_limit` parameter in the configuration file to set the upper limit of the memory quota of TiDB instances as needed. - - Distribute SQL to different instance groups according to business requirements, and handle SQL failures or retries based on the arbitrator mode of each instance group. - -You can take the following measures to ensure the execution of important SQL: - -- Use `tidb_mem_arbitrator_query_reserved` to pre-subscribe memory quota for important SQL, enhancing its memory resource isolation. -- Bind important SQL to high-priority resource groups. -- Set `tidb_mem_quota_query` to a larger value to reduce the probability that a single SQL is interrupted because it exceeds the memory quota. - From 0e8c29b74daa08ea1d624cbe610a246b76e56ed6 Mon Sep 17 00:00:00 2001 From: Zhigao TONG Date: Wed, 2 Dec 2026 14:30:33 +0800 Subject: [PATCH 08/12] Update Grafana panel name for Memory Arbitrator --- configure-memory-usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 7825a9f9720a4..a0f96e258ca63 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -326,7 +326,7 @@ TiDB internally caches the historical maximum memory usage of some SQL statement ### Monitoring and observability metrics -The `TiDB / Memory Arbitrator` panel is added to `Grafana` monitoring, containing the following metrics: +The `TiDB-Cluster / Memory Arbitrator` panel is added to `Grafana` monitoring, containing the following metrics: - `Work Mode`: the memory management mode of the TiDB instance - `Arbitration Exec`: statistics on the arbitrator processing various requests From 8c2805588805f729abaf69dc94852c8510dee83d Mon Sep 17 00:00:00 2001 From: Zhigao TONG Date: Wed, 2 Dec 2026 16:07:37 +0800 Subject: [PATCH 09/12] Remove note on forcing SQL execution under low memory Removed information about forcing SQL execution when memory is insufficient. --- configure-memory-usage.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index a0f96e258ca63..b467960352c59 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -316,8 +316,6 @@ If you want SQL to avoid the latency overhead caused by waiting for memory resou When the memory usage of a TiDB instance reaches the `95%` threshold of `tidb_server_memory_limit`, the arbitrator starts handling memory risks. If the actual memory usage cannot be reduced to a safe level in the short term or the actual memory release rate is too low, the TiDB instance faces the `OOM` risk. The arbitrator forcibly terminates SQL in order (from low to high priority, and from large to small memory quota usage), and the `reason` field in the returned error is `KILL(out-of-memory)`. -If you need to force SQL to run when memory resources are insufficient, you can set the [`tidb_mem_arbitrator_wait_averse`](/system-variables.md#tidb_mem_arbitrator_wait_averse-new-in-v900) system variable to `nolimit`. This variable makes the memory usage of the related SQL unrestricted by the arbitrator, but it might cause the TiDB instance to `OOM`. - ### Manually ensuring memory safety You can set the upper limit of the arbitrator's memory quota in a TiDB instance using the [`tidb_mem_arbitrator_soft_limit`](/system-variables.md#tidb_mem_arbitrator_soft_limit-new-in-v900) system variable or the `instance.tidb_mem_arbitrator_soft_limit` parameter in the TiDB configuration file. The smaller the upper limit, the safer the global memory, but the lower the memory resource utilization. You can use this variable to manually and quickly converge memory risks. From de0599856623c8041e04df6e9e3f1234e90d8f1a Mon Sep 17 00:00:00 2001 From: Zhigao TONG Date: Wed, 2 Dec 2026 16:08:42 +0800 Subject: [PATCH 10/12] Update possible values for memory control variable Removed 'nolimit' as a possible value for the variable. --- system-variables.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 81a6fdb6318cc..b020f26a7af2e 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4055,11 +4055,10 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified - Is controlled by the Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No - Type: Enum - Default value: `0` -- Possible values: `0`, `1`, `nolimit` +- Possible values: `0`, `1` - When [memory arbitrator mode](/configure-memory-usage.md#memory-arbitrator-mode) is enabled, this variable controls the behavior of SQL when waiting for memory resources. For more information, see [TiDB memory control](/configure-memory-usage.md#memory-arbitrator-mode). - `0` (default): Disables this feature, and the variable does not take effect. - `1`: Takes effect only in `priority` mode. SQL is automatically bound to high priority when subscribing to memory resources. When global memory resources are insufficient, the SQL execution is terminated instead of being blocked waiting. - - `nolimit`: The memory usage of SQL is not limited by the arbitrator. This value might increase the risk of OOM on the TiDB instance. From a6b3949468b8296ef3938f8b8f91936aae50b651 Mon Sep 17 00:00:00 2001 From: solotzg <9016847+solotzg@users.noreply.github.com> Date: Thu, 3 Dec 2026 09:00:35 +0800 Subject: [PATCH 11/12] docs: fix memory arbitrator links --- configure-memory-usage.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index b467960352c59..076c7cc0a7923 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -18,7 +18,7 @@ The system variable [`tidb_mem_oom_action`](/system-variables.md#tidb_mem_oom_ac -When a single SQL statement exceeds the memory quota specified by [`tidb_mem_quota_query`](#tidb_mem_quota_query), TiDB Cloud stops executing the SQL query immediately and returns an error to the client. The error information clearly shows the memory usage of each physical execution operator that consumes memory in the SQL execution process. +When a single SQL statement exceeds the memory quota specified by [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), TiDB Cloud stops executing the SQL query immediately and returns an error to the client. The error information clearly shows the memory usage of each physical execution operator that consumes memory in the SQL execution process. @@ -257,7 +257,7 @@ Starting from CLOUD.202609.1, TiDB introduces memory arbitrator mode. This mode > > This feature is experimental and is not recommended for use in the production environment. This feature might be changed or removed without prior notice. If you find a bug, report it by submitting an [issue](https://github.com/pingcap/tidb/issues) on GitHub. -You can enable memory arbitrator mode using the [`tidb_mem_arbitrator_mode`](/system-variables.md#tidb_mem_arbitrator_mode-new-in-v900) system variable or the `instance.tidb_mem_arbitrator_mode` parameter in the TiDB configuration file. +You can enable memory arbitrator mode using the [`tidb_mem_arbitrator_mode`](/system-variables.md#tidb_mem_arbitrator_mode-new-in-cloud2026091) system variable or the `instance.tidb_mem_arbitrator_mode` parameter in the TiDB configuration file. - `disable`: disables memory arbitrator mode @@ -307,7 +307,7 @@ In `priority` mode, during SQL execution, SQL dynamically subscribes to memory r - The arbitrator terminates lower-priority SQL in order (from low to high priority, and from large to small memory quota usage) to reclaim resources for higher-priority SQL. The `reason` field in the returned error is `CANCEL(out-of-quota & priority-mode)`. - If there is no terminable SQL, the subscription request continues to wait until an existing SQL finishes execution and releases resources. -If you want SQL to avoid the latency overhead caused by waiting for memory resources, you can set the [`tidb_mem_arbitrator_wait_averse`](/system-variables.md#tidb_mem_arbitrator_wait_averse-new-in-v900) system variable to `1`. +If you want SQL to avoid the latency overhead caused by waiting for memory resources, you can set the [`tidb_mem_arbitrator_wait_averse`](/system-variables.md#tidb_mem_arbitrator_wait_averse-new-in-cloud2026091) system variable to `1`. - The subscription requests of the related SQL are automatically bound to priority `HIGH`. - When global memory resources are insufficient, the arbitrator directly terminates the related SQL, and the `reason` field in the returned error is `CANCEL(out-of-quota & wait-averse)`. @@ -318,9 +318,9 @@ When the memory usage of a TiDB instance reaches the `95%` threshold of `tidb_se ### Manually ensuring memory safety -You can set the upper limit of the arbitrator's memory quota in a TiDB instance using the [`tidb_mem_arbitrator_soft_limit`](/system-variables.md#tidb_mem_arbitrator_soft_limit-new-in-v900) system variable or the `instance.tidb_mem_arbitrator_soft_limit` parameter in the TiDB configuration file. The smaller the upper limit, the safer the global memory, but the lower the memory resource utilization. You can use this variable to manually and quickly converge memory risks. +You can set the upper limit of the arbitrator's memory quota in a TiDB instance using the [`tidb_mem_arbitrator_soft_limit`](/system-variables.md#tidb_mem_arbitrator_soft_limit-new-in-cloud2026091) system variable or the `instance.tidb_mem_arbitrator_soft_limit` parameter in the TiDB configuration file. The smaller the upper limit, the safer the global memory, but the lower the memory resource utilization. You can use this variable to manually and quickly converge memory risks. -TiDB internally caches the historical maximum memory usage of some SQL statements and pre-subscribes sufficient memory quota before the next execution of the SQL. If it is known that a SQL statement has a large amount of uncontrolled memory usage, you can use the [`tidb_mem_arbitrator_query_reserved`](/system-variables.md#tidb_mem_arbitrator_query_reserved-new-in-v900) system variable to specify the quota subscribed by the SQL. The larger the value, the safer the global memory, but the lower the memory resource utilization. Pre-subscribing sufficient or excess quota can effectively ensure the isolation of memory resources for SQL. +TiDB internally caches the historical maximum memory usage of some SQL statements and pre-subscribes sufficient memory quota before the next execution of the SQL. If it is known that a SQL statement has a large amount of uncontrolled memory usage, you can use the [`tidb_mem_arbitrator_query_reserved`](/system-variables.md#tidb_mem_arbitrator_query_reserved-new-in-cloud2026091) system variable to specify the quota subscribed by the SQL. The larger the value, the safer the global memory, but the lower the memory resource utilization. Pre-subscribing sufficient or excess quota can effectively ensure the isolation of memory resources for SQL. ### Monitoring and observability metrics From e277f646810eebb805ac12fb3b15230cf7369ffe Mon Sep 17 00:00:00 2001 From: Zhigao TONG Date: Thu, 3 Dec 2026 14:11:29 +0800 Subject: [PATCH 12/12] Fix link for high memory usage alarm in documentation Updated the link for the alarm on high memory usage to point to the correct section in the same document. --- configure-memory-usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 076c7cc0a7923..270acc6173912 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -263,7 +263,7 @@ You can enable memory arbitrator mode using the [`tidb_mem_arbitrator_mode`](/sy - `standard` or `priority`: enables memory arbitrator mode. After it is enabled: - Memory resources are used with a subscribe-before-allocation mechanism and are uniformly scheduled by the memory arbitrator in each TiDB instance. - - The overall memory usage of the TiDB instance is expected not to exceed the limit of [`tidb_server_memory_limit`](/system-variables.md#tidb_server_memory_limit-new-in-v640), and the [alarm for high memory usage](#trigger-the-alarm-of-excessive-memory-usage) no longer takes effect. + - The overall memory usage of the TiDB instance is expected not to exceed the limit of [`tidb_server_memory_limit`](/system-variables.md#tidb_server_memory_limit-new-in-v640), and the [alarm for high memory usage](/configure-memory-usage.md#trigger-the-alarm-of-excessive-memory-usage) no longer takes effect. - The behavior of the following system variables remains effective: - [`tidb_mem_oom_action`](/system-variables.md#tidb_mem_oom_action-new-in-v610) - [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query)