Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate config item max-memory and add items server-memory-quota and memory-usage-alarm-ratio #4977

Merged
merged 24 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add docs
  • Loading branch information
wshwsh12 committed Nov 30, 2020
commit ecab1c852bf585babf0dc04cebe357dfd83e1d26
7 changes: 7 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,10 @@ explain select * from t where age=5;
+-------------------------------+------------+-----------+-----------------------------+-------------------------------+
3 rows in set (0.00 sec)
```

### `tidb_memory_usage_alarm_ratio`

- 作用域:SESSION
- 默认值:0.8
- TiDB 内存使用占总内存的比例超过一定阈值时会报警。该功能的详细介绍和使用方法可以参考 [`memory-usage-alarm-ratio`](/tidb-configuration-file.md#memory-usage-alarm-ratio) 。
wshwsh12 marked this conversation as resolved.
Show resolved Hide resolved
- 该变量的初始值由配置项 [`memory-usage-alarm-ratio`](/tidb-configuration-file.md#memory-usage-alarm-ratio) 配置。
wshwsh12 marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 13 additions & 4 deletions tidb-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,20 @@ TiDB 配置文件比命令行参数支持更多的选项。你可以在 [config/
+ 默认值:0
+ 默认值为 0 表示使用机器上所有的 CPU;如果设置成 n,那么 TiDB 会使用 n 个 CPU 数量。

### `max-memory`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能有用户还在使用这个配置项,废弃这个配置项是否需要说明一下呢?

  • 不推荐使用/已不能使用/已被新的配置项替代?
  • 从哪个版本废弃的?

### `server-memory-quota`

+ Prepare cache LRU 使用的最大内存限制。当 Prepare cache LRU 的内存使用超过 `performance.max-memory * (1 - prepared-plan-cache.memory-guard-ratio)` 时,会剔除 LRU 中的元素。
+ 默认值:0
+ 这个配置在 `prepared-plan-cache.enabled` 为 `true`(默认值)的情况才会生效。当 LRU 的 size 大于 `prepared-plan-cache.capacity` 时,也会剔除 LRU 中的元素。
+ TiDB 内存使用限制,单位为字节。
wshwsh12 marked this conversation as resolved.
Show resolved Hide resolved

+ 默认值:0
+ 默认值为 0 表示无内存限制。

### `memory-usage-alarm-ratio`

+ TiDB 内存使用占总内存的比例超过一定阈值时会报警。该配置项的有效范围为 0 到 1。如果配置该选项为 0 或 1,则表示关闭内存阈值报警功能。
wshwsh12 marked this conversation as resolved.
Show resolved Hide resolved
+ 默认值:0.8
+ 当内存阈值报警功能开启时,如果配置项 [`server-memory-quota`](/tidb-configuration-file.md#server-memory-quota) 未设置,则内存报警阈值为 `memory-usage-alarm-ratio * 系统内存大小`;如果 `server-memory-quota` 被设置且大于 0,则内存报警阈值为 `memory-usage-alarm-ratio * server-memory-quota`。
+ 当 TiDB 检测到内存使用超过了阈值,则会认为存在 OOM 的风险,会将当前正在执行的所有 SQL 语句中内存使用最高的 10 条语句和运行时间最长的 10 条语句以及 heap profile 记录到目录 [`tmp-storage-path/record`](/tidb-configuration-file.md#tmp-storage-path) 中,并输出一条包含关键字 `tidb-server has the risk of OOM` 的日志。
wshwsh12 marked this conversation as resolved.
Show resolved Hide resolved
+ 该值作为系统变量 [`tidb_memory_usage_alarm_ratio`](/system-variables.md#tidb_memory_usage_alarm_ratio) 的初始值。

### `txn-total-size-limit`

Expand Down