diff --git a/character-set-and-collation.md b/character-set-and-collation.md index 8f0b8d47f5a02..0271fb6c41e1f 100644 --- a/character-set-and-collation.md +++ b/character-set-and-collation.md @@ -140,7 +140,7 @@ For details about the TiDB support of the GBK character set, see [GBK](/characte In MySQL, the character set `utf8` is limited to a maximum of three bytes. This is sufficient to store characters in the Basic Multilingual Plane (BMP), but not enough to store characters such as emojis. For this, it is recommended to use the character set `utf8mb4` instead. -By default, TiDB provides the same 3-byte limit on `utf8` to ensure that data created in TiDB can still safely be restored in MySQL. This can be disabled by changing the value of `check-mb4-value-in-utf8` to `FALSE` in your TiDB configuration file. +By default, TiDB also limits the character set `utf8` to a maximum of three bytes to ensure that data created in TiDB can still safely be restored in MySQL. You can disable it by changing the value of the system variable [`tidb_check_mb4_value_in_utf8`](/system-variables.md#tidb_check_mb4_value_in_utf8) to `OFF`. The following demonstrates the default behavior when inserting a 4-byte emoji character into a table. The `INSERT` statement fails for the `utf8` character set, but succeeds for `utf8mb4`: diff --git a/configure-memory-usage.md b/configure-memory-usage.md index 29a9e14522bfc..5817e323a8e93 100644 --- a/configure-memory-usage.md +++ b/configure-memory-usage.md @@ -57,19 +57,19 @@ In this configuration, when the memory usage of a tidb-server instance reaches 3 ## Trigger the alarm of excessive memory usage -In the default configuration, a tidb-server instance prints an alarm log and records associated status files when the machine memory usage reaches 80% of its total memory. You can set the memory usage ratio threshold by configuring `memory-usage-alarm-ratio`. For detailed alarm rules, refer to the description of [`memory-usage-alarm-ratio`](/tidb-configuration-file.md#memory-usage-alarm-ratio-new-in-v409). +In the default configuration, a tidb-server instance prints an alarm log and records related status files when the machine memory usage reaches 80% of its total memory. You can set the memory usage ratio threshold by configuring the system variable [`tidb_memory_usage_alarm_ratio`](/system-variables.md#tidb_memory_usage_alarm_ratio). For detailed alarm rules, refer to the description of `tidb_memory_usage_alarm_ratio`. Note that after the alarm is triggered once, it will be triggered again only if the memory usage rate has been below the threshold for more than ten seconds and reaches the threshold again. In addition, to avoid storing excessive status files generated by alarms, currently, TiDB only retains the status files generated during the recent five alarms. The following example constructs a memory-intensive SQL statement that triggers the alarm: -1. Set `memory-usage-alarm-ratio` to `0.8`: +1. Set the value of the TiDB configuration item `instance.tidb_memory_usage_alarm_ratio` to `0.8`: {{< copyable "" >}} ```toml - [performance] - memory-usage-alarm-ratio = 0.8 + [instance] + tidb_memory_usage_alarm_ratio = 0.8 ``` 2. Execute `CREATE TABLE t(a int);` and insert 1000 rows of data. @@ -88,7 +88,7 @@ The following example constructs a memory-intensive SQL statement that triggers * `system memory total` indicates the total memory of the current system. * `system memory usage` indicates the current system memory usage. * `tidb-server memory usage` indicates the memory usage of the tidb-server instance. - * `memory-usage-alarm-ratio` indicates the value of [`memory-usage-alarm-ratio`](/tidb-configuration-file.md#memory-usage-alarm-ratio-new-in-v409). + * `memory-usage-alarm-ratio` indicates the value of [`tidb_memory_usage_alarm_ratio`](/system-variables.md#tidb_memory_usage_alarm_ratio). * `record path` indicates the directory of status files. 5. You can see a set of files in the directory of status files (In the above example, the directory is `/tmp/1000_tidb/MC4wLjAuMDo0MDAwLzAuMC4wLjA6MTAwODA=/tmp-storage/record`), including `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 format of log content in `running_sql`, refer to [`expensive-queries`](/identify-expensive-queries.md). @@ -106,7 +106,7 @@ The following example constructs a memory-intensive SQL statement that triggers TiDB supports disk spill for execution operators. When the memory usage of a SQL execution exceeds the memory quota, tidb-server can spill the intermediate data of execution operators to the disk to relieve memory pressure. Operators supporting disk spill include Sort, MergeJoin, HashJoin, and HashAgg. -- The disk spill behavior is jointly controlled by [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), [`oom-use-tmp-storage`](/tidb-configuration-file.md#oom-use-tmp-storage), [`tmp-storage-path`](/tidb-configuration-file.md#tmp-storage-path), and [`tmp-storage-quota`](/tidb-configuration-file.md#tmp-storage-quota) parameters. +- The disk spill behavior is jointly controlled by the following parameters: [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom), [`tmp-storage-path`](/tidb-configuration-file.md#tmp-storage-path), and [`tmp-storage-quota`](/tidb-configuration-file.md#tmp-storage-quota). - 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 operator is introduced in v4.0.0; disk spill for the HashAgg operator is introduced in v5.2.0. - When the SQL executions containing Sort, MergeJoin, or HashJoin cause OOM, TiDB triggers disk spill by default. When SQL executions containing HashAgg cause OOM, TiDB does not trigger disk spill by default. You can configure the system variable `tidb_executor_concurrency = 1` to trigger disk spill for HashAgg. diff --git a/dashboard/dashboard-slow-query.md b/dashboard/dashboard-slow-query.md index 34411ecc2e3d8..ee5740b722a80 100644 --- a/dashboard/dashboard-slow-query.md +++ b/dashboard/dashboard-slow-query.md @@ -11,7 +11,7 @@ By default, SQL queries with an execution time of more than 300 milliseconds are > **Note:** > -> If the slow query log is disabled, this feature will be unavailable. The slow query log is enabled by default, and you can enable or disable the slow query log through the [`enable-slow-log`](/tidb-configuration-file.md#enable-slow-log) TiDB configuration item. +> If the slow query log is disabled, this feature will be unavailable. The slow query log is enabled by default, and you can enable or disable it through the system variable [`tidb_enable_slow_log`](/system-variables.md#tidb_enable_slow_log). ## Access the page diff --git a/enable-disk-spill-encrypt.md b/enable-disk-spill-encrypt.md index 575c20405d1de..fcfb3b8225423 100644 --- a/enable-disk-spill-encrypt.md +++ b/enable-disk-spill-encrypt.md @@ -5,7 +5,7 @@ summary: Learn how to enable encryption for disk spill in TiDB. # Enable Encryption for Disk Spill -When the `oom-use-tmp-storage` configuration item is set to `true`, if the memory usage of a single SQL statement exceeds the limit of the system variable [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), some operators can save the intermediate results during execution as a temporary file to the disk and delete the file after the query is completed. +When the system variable [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom) is set to `ON`, if the memory usage of a single SQL statement exceeds the limit of the system variable [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), some operators can save the intermediate results during execution as a temporary file to the disk and delete the file after the query is completed. You can enable encryption for disk spill to prevent attackers from accessing data by reading these temporary files. diff --git a/explain-joins.md b/explain-joins.md index a50a7b01992dd..fdcbb7f6d2024 100644 --- a/explain-joins.md +++ b/explain-joins.md @@ -226,7 +226,7 @@ The `operator info` column in the `EXPLAIN` result table also records other info ### Runtime Statistics -If [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) (default value: 1GB) is exceeded, TiDB will attempt to use temporary storage on condition that the `oom-use-tmp-storage` value is `true` (default). This means that the `Build` operator used as part of the hash join might be created on disk. Runtime statistics such as memory usage are visible in the `execution info` of the `EXPLAIN ANALYZE` result table. The following example shows the output of `EXPLAIN ANALYZE` with a 1GB (default) `tidb_mem_quota_query` quota, and a 500MB quota. At 500MB, disk is used for temporary storage: +If [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) (default value: 1 GB) is exceeded, and the [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom) value is `ON` (default), TiDB will attempt to use temporary storage, and might create the `Build` operator (used as part of the hash join) on disk. Runtime statistics such as memory usage are recorded in the `execution info` of the `EXPLAIN ANALYZE` result table. The following example shows the output of `EXPLAIN ANALYZE` with a 1 GB (default) and a 500 MB quota for `tidb_mem_quota_query`. At 500 MB, disk is used for temporary storage: ```sql EXPLAIN ANALYZE SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id; diff --git a/faq/manage-cluster-faq.md b/faq/manage-cluster-faq.md index 3dea14fd0cb15..a195904a7d55b 100644 --- a/faq/manage-cluster-faq.md +++ b/faq/manage-cluster-faq.md @@ -226,7 +226,7 @@ The TiClient Region Error indicator describes the error types and metrics that a ### What's the maximum number of concurrent connections that TiDB supports? -By default, there is no limit on the maximum number of connections per TiDB server. If too large concurrency leads to an increase of response time, it is recommended to increase the capacity by adding TiDB nodes. +By default, there is no limit on the maximum number of connections per TiDB server. If needed, you can limit the maximum number of connections by setting `instance.max_connections` in the `config.toml` file, or changing the value of the system variable [`max_connections`](/system-variables.md#max_connections). If too large concurrency leads to an increase of response time, it is recommended to increase the capacity by adding TiDB nodes. ### How to view the creation time of a table? diff --git a/faq/sql-faq.md b/faq/sql-faq.md index 851b9a97fbfbf..31bb2237cdd76 100644 --- a/faq/sql-faq.md +++ b/faq/sql-faq.md @@ -197,7 +197,7 @@ The display content of TiDB `SHOW PROCESSLIST` is almost the same as that of MyS ## How to control or change the execution priority of SQL commits? -TiDB supports changing the priority on a [per-session](/system-variables.md#tidb_force_priority), [global](/tidb-configuration-file.md#force-priority) or individual statement basis. Priority has the following meaning: +TiDB supports changing the priority on a [per-session](/system-variables.md#tidb_force_priority), [global](/system-variables.md#tidb_force_priority) or individual statement basis. Priority has the following meaning: - `HIGH_PRIORITY`: this statement has a high priority, that is, TiDB gives priority to this statement and executes it first. diff --git a/identify-slow-queries.md b/identify-slow-queries.md index 4fc3e608c2e50..ec4b09076fc04 100644 --- a/identify-slow-queries.md +++ b/identify-slow-queries.md @@ -5,9 +5,9 @@ summary: Use the slow query log to identify problematic SQL statements. # Identify Slow Queries -To help users identify slow queries, analyze and improve the performance of SQL execution, TiDB outputs the statements whose execution time exceeds [slow-threshold](/tidb-configuration-file.md#slow-threshold) (The default value is 300 milliseconds) to [slow-query-file](/tidb-configuration-file.md#slow-query-file) (The default value is "tidb-slow.log"). +To help users identify slow queries, analyze and improve the performance of SQL execution, TiDB outputs the statements whose execution time exceeds [`tidb_enable_slow_log`](/system-variables.md#tidb_enable_slow_log) (The default value is 300 milliseconds) to [slow-query-file](/tidb-configuration-file.md#slow-query-file) (The default value is "tidb-slow.log"). -TiDB enables the slow query log by default. You can enable or disable the feature by modifying the configuration [`enable-slow-log`](/tidb-configuration-file.md#enable-slow-log). +TiDB enables the slow query log by default. You can enable or disable the feature by modifying the system variable [`tidb_enable_slow_log`](/system-variables.md#tidb_enable_slow_log). ## Usage example diff --git a/security-compatibility-with-mysql.md b/security-compatibility-with-mysql.md index 8ee4c57680f45..bda50f35abbd2 100644 --- a/security-compatibility-with-mysql.md +++ b/security-compatibility-with-mysql.md @@ -9,7 +9,7 @@ TiDB supports similar security functionality to MySQL 5.7, with the following ex - Column level permissions are not supported - Password expiry, as well as password last-changed tracking and password lifetime are not supported [#9709](https://github.com/pingcap/tidb/issues/9709) -- The permission attributes `max_questions`, `max_updated`, `max_connections`, `max_user_connections` are not supported +- These permission attributes are not supported: `max_questions`, `max_updated`, and `max_user_connections` - Password validation is not currently supported [#9741](https://github.com/pingcap/tidb/issues/9741) ## Authentication plugin status diff --git a/system-variables.md b/system-variables.md index 900beed6fc645..1372540d2c802 100644 --- a/system-variables.md +++ b/system-variables.md @@ -349,8 +349,8 @@ This variable is an alias for [`last_insert_id`](#last_insert_id). - Type: Integer - Default value: `0` - Range: `[0, 100000]` -- The maximum number of connections permitted for a single TiDB instance. -- The value of `0` means no limit. +- The maximum number of concurrent connections permitted for a single TiDB instance. This variable can be used for resources control. +- The default value `0` means no limit. When the value of this variable is larger than `0`, and the number of connections reaches the value, the TiDB server rejects new connections from clients. ### max_execution_time @@ -1244,6 +1244,14 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - `ON` indicates that primary keys are created as clustered indexes by default. - `INT_ONLY` indicates that the behavior is controlled by the configuration item `alter-primary-key`. If `alter-primary-key` is set to `true`, all primary keys are created as non-clustered indexes by default. If it is set to `false`, only the primary keys which consist of an integer column are created as clustered indexes. +### tidb_enable_ddl + +- Scope: GLOBAL +- Persists to cluster: No, only applicable to the current TiDB instance that you are connecting to. +- Default value: `ON` +- Possible values: `OFF`, `ON` +- This variable controls whether the corresponding TiDB server can run DDL statements or not. + ### tidb_enable_collect_execution_info @@ -1609,7 +1617,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a -- When the operator that reads data has only one thread left and the memory usage of a single SQL statement continues to exceed [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), this SQL statement triggers other memory control behaviors, such as [spilling data to disk](/tidb-configuration-file.md#oom-use-tmp-storage). +- When the operator that reads data has only one thread left and the memory usage of a single SQL statement constantly exceeds [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), this SQL statement triggers other memory control behaviors, such as [spilling data to disk](/system-variables.md#tidb_enable_tmp_storage_on_oom). - This variable controls memory usage effectively when an SQL statement only reads data. If computing operations (such as join or aggregation operations) are required, memory usage might not be under the control of `tidb_mem_quota_query`, which increases the risk of OOM. @@ -1636,6 +1644,15 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - Default value: `ON` - This variable is used to control whether to enable the slow log feature. +### tidb_enable_tmp_storage_on_oom + +- Scope: GLOBAL +- Persists to cluster: Yes +- Default value: `ON` +- Value options: `OFF`, `ON` +- Controls whether to enable the temporary storage for some operators when a single SQL statement exceeds the memory quota specified by the system variable [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query). +- Before v6.3.0, you can enable or disable this feature by using the TiDB configuration item `oom-use-tmp-storage`. After upgrading the cluster to v6.3.0 or a later version, the TiDB cluster will initialize this variable using the value of `oom-use-tmp-storage` automatically. After that, changing the value of `oom-use-tmp-storage` **does not** take effect anymore. + ### tidb_enable_stmt_summary New in v3.0.4 - Scope: GLOBAL @@ -2433,14 +2450,14 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified -- TiDB triggers an alarm when the percentage of the memory it takes exceeds a certain threshold. For the detailed usage description of this feature, see [`memory-usage-alarm-ratio`](/tidb-configuration-file.md#memory-usage-alarm-ratio-new-in-v409). -- You can set the initial value of this variable by configuring [`memory-usage-alarm-ratio`](/tidb-configuration-file.md#memory-usage-alarm-ratio-new-in-v409). +- TiDB triggers an alarm when the percentage of the memory it consumes exceeds a certain threshold. For the detailed usage description of this feature, see [`tidb_memory_usage_alarm_ratio`](/tidb-configuration-file.md#tidb_memory_usage_alarm_ratio). +- You can set the initial value of this variable by configuring [`tidb_memory_usage_alarm_ratio`](/tidb-configuration-file.md#tidb_memory_usage_alarm_ratio). -- TiDB triggers an alarm when the percentage of the memory it takes exceeds a certain threshold. For the detailed usage description of this feature, see [`memory-usage-alarm-ratio`](https://docs.pingcap.com/tidb/stable/tidb-configuration-file#memory-usage-alarm-ratio-new-in-v409). +- TiDB triggers an alarm when the percentage of the memory it consumes exceeds a certain threshold. For the detailed usage description of this feature, see [`tidb_memory_usage_alarm_ratio`](https://docs.pingcap.com/tidb/stable/tidb-configuration-file#tidb_memory_usage_alarm_ratio). diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 5ce93791bd9a2..9804a598e7ab7 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -27,6 +27,10 @@ The TiDB configuration file supports more options than command-line parameters. ### `oom-use-tmp-storage` +> **Warning:** +> +> Since v6.3.0, this configuration item is deprecated and superseded by the system variable [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom). When the TiDB cluster is upgraded to v6.3.0 or a later version, it will automatically initialize the variable with the value of `oom-use-tmp-storage`. After that, changing the value of `oom-use-tmp-storage` **does not** take effect anymore. + + Controls whether to enable the temporary storage for some operators when a single SQL statement exceeds the memory quota specified by the system variable [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query). + Default value: `true` @@ -34,7 +38,7 @@ The TiDB configuration file supports more options than command-line parameters. + Specifies the temporary storage path for some operators when a single SQL statement exceeds the memory quota specified by the system variable [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query). + Default value: `/_tidb/MC4wLjAuMDo0MDAwLzAuMC4wLjA6MTAwODA=/tmp-storage`. `MC4wLjAuMDo0MDAwLzAuMC4wLjA6MTAwODA=` is the `Base64` encoding result of `:/:`. -+ This configuration takes effect only when `oom-use-tmp-storage` is `true`. ++ This configuration takes effect only when the system variable [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom) is `ON`. ### `tmp-storage-quota` @@ -61,6 +65,7 @@ The TiDB configuration file supports more options than command-line parameters. - Determines whether to enable the `utf8mb4` character check. When this feature is enabled, if the character set is `utf8` and the `mb4` characters are inserted in `utf8`, an error is returned. - Default value: `false` +- Since v6.1.0, whether to enable the `utf8mb4` character check is determined by the TiDB configuration item `instance.tidb_check_mb4_value_in_utf8` or the system variable `tidb_check_mb4_value_in_utf8`. `check-mb4-value-in-utf8` still takes effect. But if both `check-mb4-value-in-utf8` and `instance.tidb_check_mb4_value_in_utf8` are set, the latter takes effect. ### `treat-old-version-utf8-as-utf8mb4` @@ -108,6 +113,7 @@ The TiDB configuration file supports more options than command-line parameters. - The maximum number of concurrent client connections allowed in TiDB. It is used to control resources. - Default value: `0` - By default, TiDB does not set limit on the number of concurrent client connections. When the value of this configuration item is greater than `0` and the number of actual client connections reaches this value, the TiDB server rejects new client connections. +- Since v6.2.0, the TiDB configuration item [`instance.max_connections`](/tidb-configuration-file.md#max_connections) or the system variable [`max_connections`](/system-variables.md#max_connections) is used to set the maximum number of concurrent client connections allowed in TiDB. `max-server-connections` still takes effect. But if `max-server-connections` and `instance.max_connections` are set at the same time, the latter takes effect. ### `max-index-length` @@ -208,6 +214,7 @@ Configuration items related to log. - Determines whether to enable the slow query log. - Default value: `true` - To enable the slow query log, set `enable-slow-log` to `true`. Otherwise, set it to `false`. +- Since v6.1.0, whether to enable slow query log is determined by the TiDB configuration item [`instance.tidb_enable_slow_log`](/tidb-configuration-file.md#tidb_enable_slow_log) or the system variable [`tidb_enable_slow_log`](/system-variables.md#tidb_enable_slow_log). `enable-slow-log` still takes effect. But if `enable-slow-log` and `instance.tidb_enable_slow_log` are set at the same time, the latter takes effect. ### `slow-query-file` @@ -222,12 +229,13 @@ Configuration items related to log. - Default value: `300` - Unit: Milliseconds - If the value in a query is larger than the default value, it is a slow query and is output to the slow log. +- Since v6.1.0, the threshold value of consumed time in the slow log is specified by the TiDB configuration item [`instance.tidb_slow_log_threshold`](/tidb-configuration-file.md#tidb_slow_log_threshold) or the system variable [`tidb_slow_log_threshold`](/system-variables.md#tidb_slow_log_threshold). `slow-threshold` still takes effect. But if `slow-threshold` and `instance.tidb_slow_log_threshold` are set at the same time, the latter takes effect. ### `record-plan-in-slow-log` -+ Determines whether to record execution plans in the slow log. -+ Default value: `1` -+ `0` means to disable, and `1` (by default) means to enable. The value of this parameter is the initial value of the [`tidb_record_plan_in_slow_log`](/system-variables.md#tidb_record_plan_in_slow_log) system variable. +- Determines whether to record execution plans in the slow log. +- Default value: `1` +- Since v6.1.0, whether to record execution plans in the slow log is determined by the TiDB configuration item [`instance.tidb_record_plan_in_slow_log`](/tidb-configuration-file.md#tidb_record_plan_in_slow_log) or the system variable [`tidb_record_plan_in_slow_log`](/system-variables.md#tidb_record_plan_in_slow_log). `record-plan-in-slow-log` still takes effect. But if `record-plan-in-slow-log` and `instance.tidb_record_plan_in_slow_log` are set at the same time, the latter takes effect. ### `expensive-threshold` @@ -352,6 +360,7 @@ Configuration items related to performance. + When the memory usage alarm is enabled, if [`server-memory-quota`](/tidb-configuration-file.md#server-memory-quota-new-in-v409) is not set, then the threshold of memory usage is ```the `memory-usage-alarm-ratio` value * the system memory size```; if `server-memory-quota` is set to a value greater than 0, then the threshold of memory usage is ```the `memory-usage-alarm-ratio` value * the `server-memory-quota` value```. + When TiDB detects that the memory usage of the tidb-server instance exceeds the threshold, it considers that there might be a risk of OOM. Therefore, it records ten SQL statements with the highest memory usage, ten SQL statements with the longest running time, and the heap profile among all SQL statements currently being executed to the directory [`tmp-storage-path/record`](/tidb-configuration-file.md#tmp-storage-path) and outputs a log containing the keyword `tidb-server has the risk of OOM`. + The value of this configuration item is the initial value of the system variable [`tidb_memory_usage_alarm_ratio`](/system-variables.md#tidb_memory_usage_alarm_ratio). ++ Since v6.1.0, this threshold is determined by the TiDB configuration item [`instance.tidb_memory_usage_alarm_ratio`](/tidb-configuration-file.md#tidb_memory_usage_alarm_ratio) or the system variable [`tidb_memory_usage_alarm_ratio`](/system-variables.md#tidb_memory_usage_alarm_ratio). `memory-usage-alarm-ratio` still takes effect. But if `memory-usage-alarm-ratio` and `instance.tidb_memory_usage_alarm_ratio` are set at the same time, the latter takes effect. ### `max-txn-ttl` @@ -422,6 +431,7 @@ Configuration items related to performance. - Sets the priority for all statements. - Default value: `NO_PRIORITY` - Value options: The default value `NO_PRIORITY` means that the priority for statements is not forced to change. Other options are `LOW_PRIORITY`, `DELAYED`, and `HIGH_PRIORITY` in ascending order. +- Since v6.1.0, the priority for all statements is determined by the TiDB configuration item [`instance.tidb_force_priority`](/tidb-configuration-file.md#tidb_force_priority) or the system variable [`tidb_force_priority`](/system-variables.md#tidb_force_priority). `force-priority` still takes effect. But if `force-priority` and `instance.tidb_force_priority` are set at the same time, the latter takes effect. ### `distinct-agg-push-down` @@ -697,6 +707,76 @@ Configuration items related to read isolation. - Default value: ["tikv", "tiflash", "tidb"], indicating that the engine is automatically selected by the optimizer. - Value options: Any combinations of "tikv", "tiflash", and "tidb", for example, ["tikv", "tidb"] or ["tiflash", "tidb"] +## instance + +### `tidb_enable_collect_execution_info` + +- This configuration controls whether to record the execution information of each operator in the slow query log. +- Default value: `true` +- Before v6.1.0, this configuration is set by `enable-collect-execution-info`. + +### `tidb_enable_slow_log` + +- This configuration is used to control whether to enable the slow log feature. +- Default value: `true` +- Value options: `true` or `false` +- Before v6.1.0, this configuration is set by `enable-slow-log`. + +### `tidb_slow_log_threshold` + +- This configuration is used to output the threshold value of the time consumed by the slow log. When the time consumed by a query is larger than this value, this query is considered as a slow log and its log is output to the slow query log. +- Default value: `300` +- Range: `[-1, 9223372036854775807]` +- Unit: Milliseconds +- Before v6.1.0, this configuration is set by `slow-threshold`. + +### `tidb_record_plan_in_slow_log` + +- This configuration is used to control whether to include the execution plan of slow queries in the slow log. +- Default value: `1` +- Value options: `1` (enabled, default) or `0` (disabled). +- The value of this configuration will initialize the value of system variable [`tidb_record_plan_in_slow_log`](/system-variables.md#tidb_record_plan_in_slow_log) +- Before v6.1.0, this configuration is set by `record-plan-in-slow-log`. + +### `tidb_force_priority` + +- This configuration is used to change the default priority for statements executed on a TiDB server. +- Default value: `NO_PRIORITY` +- The default value `NO_PRIORITY` means that the priority for statements is not forced to change. Other options are `LOW_PRIORITY`, `DELAYED`, and `HIGH_PRIORITY` in ascending order. +- Before v6.1.0, this configuration is set by `force-priority`. + +### `max_connections` + +- The maximum number of connections permitted for a single TiDB instance. It can be used for resources control. +- Default value: `0` +- Range: `[0, 100000]` +- The default value `0` means no limit. When the value of this variable is larger than `0`, and the number of connections reaches the value, the TiDB server will reject new connections from clients. +- The value of this configuration will initialize the value of system variable [`max_connections`](/system-variables.md#max_connections) +- Before v6.2.0, this configuration is set by `max-server-connections`. + +### `tidb_memory_usage_alarm_ratio` + +- TiDB triggers an alarm when the memory usage of tidb-server instance exceeds a certain threshold. The valid value for this configuration item ranges from `0` to `1`. If it is configured as `0` or `1`, this alarm feature is disabled. +- Default value: `0.8` +- When the memory usage alarm is enabled, if [`server-memory-quota`](/tidb-configuration-file.md#server-memory-quota-new-in-v409) is not set, then the threshold of memory usage is ```the `memory-usage-alarm-ratio` value * the system memory size```; if `server-memory-quota` is set to a value greater than 0, then the threshold of memory usage is ```the `memory-usage-alarm-ratio` value * the `server-memory-quota` value```. +- When TiDB detects that the memory usage of the tidb-server instance exceeds the threshold, it considers that there might be a risk of OOM. Therefore, it records the following information to the directory [`tmp-storage-path/record`](/tidb-configuration-file.md#tmp-storage-path): + - Top 10 SQL statements with the highest memory usage + - Top 10 SQL statements with the longest running time + - The heap profile among all SQL statements currently being executed + + It then outputs a log containing the keyword `tidb-server has the risk of OOM`. + +- The value of this configuration will initialize the value of system variable [`tidb_memory_usage_alarm_ratio`](/system-variables.md#tidb_memory_usage_alarm_ratio) +- Before v6.1.0, this configuration is set by `memory-usage-alarm-ratio`. + +### `tidb_enable_ddl` + +- This configuration controls whether the corresponding TiDB instance can run DDL statements or not. +- Default value: `true` +- Possible values: `OFF`, `ON` +- The value of this configuration will initialize the value of the system variable [`tidb_enable_ddl`](/system-variables.md#tidb_enable_ddl) +- Before v6.3.0, this configuration is set by `run-ddl`. + ## proxy-protocol Configuration items related to the PROXY protocol. diff --git a/tiup/tiup-cluster-topology-reference.md b/tiup/tiup-cluster-topology-reference.md index dac7ed3de4d1e..0cbcfa0bde085 100644 --- a/tiup/tiup-cluster-topology-reference.md +++ b/tiup/tiup-cluster-topology-reference.md @@ -142,10 +142,10 @@ A `server_configs` configuration example is as follows: ```yaml server_configs: tidb: - run-ddl: true lease: "45s" split-table: true token-limit: 1000 + instance.tidb_enable_ddl: true tikv: log-level: "info" readpool.unified.min-thread-count: 1