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

sql-infra: document for resource control feature #12655

Merged
merged 120 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
215d994
*: document for resource control feature
BornChanger Jan 12, 2023
9c82cf6
*: minor adjustment
BornChanger Jan 12, 2023
1d92cda
Apply suggestions from code review
hfxsd Jan 13, 2023
1b34d90
Update tidb-resource-control.md
hfxsd Jan 13, 2023
f2bcbe3
Update tidb-resource-control.md
hfxsd Jan 13, 2023
1be205b
fix format issues
hfxsd Jan 13, 2023
d929ad4
*: address comments
BornChanger Jan 13, 2023
6c7a2e6
*: add tikv config
BornChanger Jan 13, 2023
3200a64
*: address comments round 2
BornChanger Jan 13, 2023
b283bbb
polished
hfxsd Jan 17, 2023
bbe2f0d
polished two more docs
hfxsd Jan 17, 2023
c232bca
*: add show create resoruce group command
BornChanger Jan 18, 2023
fd707f3
Update tidb-resource-control.md
hfxsd Jan 19, 2023
6ebbd46
*: adjust some expression
BornChanger Jan 19, 2023
8de92ce
Update tidb-resource-control.md
hfxsd Jan 19, 2023
daa5d45
Merge branch 'resource_control' of https://github.com/BornChanger/doc…
hfxsd Jan 19, 2023
d9618c6
Update tidb-resource-control.md
hfxsd Jan 19, 2023
dc6d4b1
Update tidb-resource-control.md
hfxsd Jan 19, 2023
6506dd3
Update tidb-resource-control.md
hfxsd Jan 19, 2023
4fa1aef
Update sql-statements/sql-statement-show-create-resource-group.md
hfxsd Jan 19, 2023
a284f23
*: fix some typo
BornChanger Jan 19, 2023
6c2eb4a
Update sql-statements/sql-statement-alter-resource-group.md
BornChanger Jan 19, 2023
af3bb25
Update sql-statements/sql-statement-create-resource-group.md
BornChanger Jan 19, 2023
a64a4c8
Update sql-statements/sql-statement-create-resource-group.md
BornChanger Jan 19, 2023
8f96776
Update sql-statements/sql-statement-drop-resource-group.md
BornChanger Jan 19, 2023
447dbff
Update sql-statements/sql-statement-alter-resource-group.md
BornChanger Jan 19, 2023
4a746cd
Update sql-statements/sql-statement-drop-resource-group.md
BornChanger Jan 19, 2023
421b56c
*: fix show resource group command sample
BornChanger Jan 19, 2023
7f14f8a
Update tidb-resource-control.md
hfxsd Jan 19, 2023
8fc294d
Update tidb-resource-control.md
hfxsd Jan 19, 2023
64a4066
Update tidb-resource-control.md
hfxsd Jan 19, 2023
6a0c539
Update sql-statements/sql-statement-alter-resource-group.md
hfxsd Jan 28, 2023
25bd294
Update sql-statements/sql-statement-create-resource-group.md
hfxsd Jan 28, 2023
0c9a494
Apply suggestions from code review
hfxsd Jan 28, 2023
8387e9e
polished wording
hfxsd Jan 28, 2023
e4e5473
*: add privilege and new is table
BornChanger Jan 30, 2023
c770dfd
*: refresh privileges and processlist
BornChanger Jan 30, 2023
6bc7998
Update sql-statements/sql-statement-alter-resource-group.md
BornChanger Jan 31, 2023
9621bf4
Update sql-statements/sql-statement-drop-resource-group.md
BornChanger Jan 31, 2023
99c9cf9
Update tidb-resource-control.md
BornChanger Jan 31, 2023
a16798a
Update tidb-resource-control.md
BornChanger Jan 31, 2023
d1a52b4
Update sql-statements/sql-statement-create-resource-group.md
BornChanger Jan 31, 2023
8d773ca
Apply suggestions from code review
hfxsd Jan 31, 2023
0960715
Update information-schema/information-schema-processlist.md
hfxsd Feb 1, 2023
1e2df20
Apply suggestions from code review
hfxsd Feb 1, 2023
ba6d15b
Update information-schema-resource-groups.md
hfxsd Feb 1, 2023
5658475
Update information-schema/information-schema-processlist.md
hfxsd Feb 1, 2023
e7b62cd
Update TOC.md
hfxsd Feb 1, 2023
1e92cc1
Merge branch 'resource_control' of https://github.com/BornChanger/doc…
hfxsd Feb 1, 2023
499cbd6
Merge remote-tracking branch 'upstream/master' into pr/12655
hfxsd Feb 1, 2023
f4adffa
Update privilege-management.md
hfxsd Feb 1, 2023
3687905
Update sql-statement-show-create-resource-group.md
hfxsd Feb 1, 2023
0ef0a49
Apply suggestions from code review
hfxsd Feb 1, 2023
b005c0a
Update tidb-resource-control.md
hfxsd Feb 2, 2023
70691d1
Update sql-statements/sql-statement-show-create-resource-group.md
hfxsd Feb 2, 2023
2a1a9fc
Update tidb-resource-control.md
hfxsd Feb 2, 2023
e05eae1
Merge branch 'resource_control' of https://github.com/BornChanger/doc…
hfxsd Feb 2, 2023
292e4d3
Update tidb-RU.md
hfxsd Feb 2, 2023
9534d6c
Apply suggestions from code review
hfxsd Feb 2, 2023
bc6bdb0
Update information-schema/information-schema-processlist.md
BornChanger Feb 2, 2023
9a3dcdb
Apply suggestions from code review
hfxsd Feb 2, 2023
d486943
Update the Resource Control Dashboard introduction
JmPotato Feb 3, 2023
3778dfa
Merge remote-tracking branch 'upstream/master' into pr/12655
hfxsd Feb 3, 2023
70e5589
Merge branch 'resource_control' of https://github.com/BornChanger/doc…
hfxsd Feb 3, 2023
a8c83b1
polished resource control dashboard
hfxsd Feb 3, 2023
078e816
Update grafana-resource-control-dashboard.md
hfxsd Feb 3, 2023
cb7da50
Apply suggestions from code review
hfxsd Feb 3, 2023
b018c2e
*: address comments
BornChanger Feb 1, 2023
b078d2b
Merge remote-tracking branch 'upstream/master' into pr/12655
hfxsd Feb 3, 2023
d3f7145
Update tidb-resource-control.md
hfxsd Feb 3, 2023
3da56cc
polished brian's latest updates
hfxsd Feb 3, 2023
235c41d
Update grafana-resource-control-dashboard.md
BornChanger Feb 3, 2023
b9252aa
Update grafana-resource-control-dashboard.md
BornChanger Feb 3, 2023
d72b195
updated links
hfxsd Feb 6, 2023
6817296
Apply suggestions from code review
hfxsd Feb 6, 2023
fe49769
Update tidb-resource-control.md
hfxsd Feb 6, 2023
e758150
Merge branch 'resource_control' of https://github.com/BornChanger/doc…
hfxsd Feb 6, 2023
e0cc66b
Update tidb-resource-control.md
hfxsd Feb 6, 2023
7ad85c7
Apply suggestions from code review
hfxsd Feb 6, 2023
c216e4b
*: address comments
BornChanger Feb 6, 2023
1a67cee
Update information-schema/information-schema-resource-groups.md
hfxsd Feb 6, 2023
28f963e
refined newly added content
hfxsd Feb 6, 2023
24cc536
*: adjust the fomula
BornChanger Feb 7, 2023
d67b87c
Update tidb-resource-control.md
hfxsd Feb 7, 2023
5eac928
polished some wording
hfxsd Feb 7, 2023
e705852
Update grafana-resource-control-dashboard.md
hfxsd Feb 7, 2023
73f965e
Update grafana-resource-control-dashboard.md
hfxsd Feb 7, 2023
8e4b0b3
Update sql-statements/sql-statement-show-privileges.md
hfxsd Feb 7, 2023
6f36716
Update tikv-configuration-file.md
BornChanger Feb 7, 2023
c29731d
Apply suggestions from code review
hfxsd Feb 7, 2023
7c39888
*: address some comments
BornChanger Feb 7, 2023
0cc21da
*: adjust RU fomula
BornChanger Feb 7, 2023
abb80be
*: adjust resource_groups table
BornChanger Feb 7, 2023
94f586d
Update sql-statements/sql-statement-alter-resource-group.md
BornChanger Feb 7, 2023
bc48680
Update sql-statements/sql-statement-create-resource-group.md
BornChanger Feb 7, 2023
1965af0
Update sql-statements/sql-statement-drop-resource-group.md
BornChanger Feb 7, 2023
f07cca8
Update mysql-compatibility.md
hfxsd Feb 8, 2023
d48be21
Update mysql-compatibility.md
hfxsd Feb 8, 2023
7ec95e5
*: remove RU_TOKENS
BornChanger Feb 8, 2023
0d1c77c
*: refine some wording
BornChanger Feb 8, 2023
a7c6c80
Update sql-statements/sql-statement-show-create-resource-group.md
BornChanger Feb 8, 2023
a3ab88f
Update tidb-resource-control.md
BornChanger Feb 8, 2023
585141c
mention tikv grpc resource group metrics
Connor1996 Feb 8, 2023
68b0b58
*: address comments
BornChanger Feb 9, 2023
679791e
Update tidb-resource-control.md
hfxsd Feb 9, 2023
f310b3b
Update tidb-resource-control.md
hfxsd Feb 12, 2023
3847c3a
Apply suggestions from code review
hfxsd Feb 12, 2023
0ef8923
Update tidb-resource-control.md
hfxsd Feb 15, 2023
18f39ea
Merge branch 'resource_control' of https://github.com/BornChanger/doc…
hfxsd Feb 15, 2023
ff16ad9
Update tidb-resource-control.md
hfxsd Feb 16, 2023
e82eaca
Update tidb-resource-control.md
hfxsd Feb 16, 2023
1fc74c6
Update information-schema/information-schema-resource-groups.md
BornChanger Feb 16, 2023
78e7d00
Update sql-statements/sql-statement-alter-resource-group.md
BornChanger Feb 16, 2023
258597b
Update sql-statements/sql-statement-alter-resource-group.md
BornChanger Feb 16, 2023
b66d8f5
Apply suggestions from code review
hfxsd Feb 17, 2023
5b18731
Apply suggestions from code review
hfxsd Feb 17, 2023
0015425
Update grafana-tikv-dashboard.md
hfxsd Feb 17, 2023
7e42d73
Update grafana-resource-control-dashboard.md
hfxsd Feb 17, 2023
540b7e4
Merge remote-tracking branch 'upstream/master' into pr/12655
hfxsd Feb 17, 2023
0a15cc1
Update tidb-resource-control.md
hfxsd Feb 17, 2023
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
7 changes: 7 additions & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
- [使用 Dumpling 和 TiDB Lightning 备份与恢复](/backup-and-restore-using-dumpling-lightning.md)
- [备份与恢复 RawKV](/br/rawkv-backup-and-restore.md)
- [增量备份与恢复](/br/br-incremental-guide.md)
- [使用资源管控 (Resource Control) 实现资源隔离](/tidb-resource-control.md)
- [修改时区](/configure-time-zone.md)
- [日常巡检](/daily-check.md)
- [TiFlash 常用运维操作](/tiflash/maintain-tiflash.md)
Expand Down Expand Up @@ -629,6 +630,7 @@
- [TiKV 面板](/grafana-tikv-dashboard.md)
- [TiFlash 监控指标](/tiflash/monitor-tiflash.md)
- [TiCDC 监控指标](/ticdc/monitor-ticdc.md)
- [Resource Control 监控指标](/grafana-resource-control-dashboard.md)
- 安全加固
- [为 TiDB 客户端服务端间通信开启加密传输](/enable-tls-between-clients-and-servers.md)
- [为 TiDB 组件间通信开启加密传输](/enable-tls-between-components.md)
Expand Down Expand Up @@ -668,6 +670,7 @@
- [`ALTER INDEX`](/sql-statements/sql-statement-alter-index.md)
- [`ALTER INSTANCE`](/sql-statements/sql-statement-alter-instance.md)
- [`ALTER PLACEMENT POLICY`](/sql-statements/sql-statement-alter-placement-policy.md)
- [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md)
- [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md)
- [`ALTER TABLE COMPACT`](/sql-statements/sql-statement-alter-table-compact.md)
- [`ALTER USER`](/sql-statements/sql-statement-alter-user.md)
Expand All @@ -683,6 +686,7 @@
- [`CREATE DATABASE`](/sql-statements/sql-statement-create-database.md)
- [`CREATE INDEX`](/sql-statements/sql-statement-create-index.md)
- [`CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-create-placement-policy.md)
- [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md)
- [`CREATE ROLE`](/sql-statements/sql-statement-create-role.md)
- [`CREATE SEQUENCE`](/sql-statements/sql-statement-create-sequence.md)
- [`CREATE TABLE LIKE`](/sql-statements/sql-statement-create-table-like.md)
Expand All @@ -699,6 +703,7 @@
- [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md)
- [`DROP INDEX`](/sql-statements/sql-statement-drop-index.md)
- [`DROP PLACEMENT POLICY`](/sql-statements/sql-statement-drop-placement-policy.md)
- [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md)
- [`DROP ROLE`](/sql-statements/sql-statement-drop-role.md)
- [`DROP SEQUENCE`](/sql-statements/sql-statement-drop-sequence.md)
- [`DROP STATS`](/sql-statements/sql-statement-drop-stats.md)
Expand Down Expand Up @@ -749,6 +754,7 @@
- [`SHOW [FULL] COLUMNS FROM`](/sql-statements/sql-statement-show-columns-from.md)
- [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md)
- [`SHOW CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-show-create-placement-policy.md)
- [`SHOW CREATE RESOURCE GROUP`](/sql-statements/sql-statement-show-create-resource-group.md)
- [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md)
- [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md)
- [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md)
Expand Down Expand Up @@ -875,6 +881,7 @@
- [`PLACEMENT_POLICIES`](/information-schema/information-schema-placement-policies.md)
- [`PROCESSLIST`](/information-schema/information-schema-processlist.md)
- [`REFERENTIAL_CONSTRAINTS`](/information-schema/information-schema-referential-constraints.md)
- [`RESOURCE_GROUPS`](/information-schema/information-schema-resource-groups.md)
- [`SCHEMATA`](/information-schema/information-schema-schemata.md)
- [`SEQUENCES`](/information-schema/information-schema-sequences.md)
- [`SESSION_VARIABLES`](/information-schema/information-schema-session-variables.md)
Expand Down
36 changes: 36 additions & 0 deletions grafana-resource-control-dashboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: 资源管控 (Resource Control) 监控指标详解
summary: 了解资源管控 (Resource Control) 的 Grafana Dashboard 中所展示的关键指标。
---

# 资源管控 (Resource Control) 监控指标详解

使用 TiUP 部署 TiDB 集群时,可以一键部署监控系统 (Prometheus & Grafana)。监控架构请参见 [TiDB 监控框架概述](/tidb-monitoring-framework.md)。

目前 Grafana Dashboard 整体分为 PD、TiDB、TiKV、Node_exporter、Overview、Performance_overview 等。

如果你的集群配置了 [Resource Control](tidb-resource-control.md) ,通过观察 Resource Control 面板上的 Metrics,你可以了解当前集群整体的资源消耗状态。
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

以下为 **Resource Control** 关键监控指标的说明。

## Request Unit 相关指标

- RU:以 Resource Group 为单位进行实时统计的 [Request Unit (RU)](/tidb-resource-control.md#什么是-request-unit-ru) 消耗信息。`total` 为当前所有 Resource Group 消耗的 Request Unit 之和。每个 Resource Group 的 Request Unit 消耗等于其读消耗 (Read Request Unit) 和写消耗 (Write Request Unit) 之和。
- RU Per Query:平均每个 SQL 语句消耗的 Request Unit 数量。计算方法是将前述 Request Unit 监控指标除以当前每秒执行的 SQL 语句数量。
- RRU:以 Resource Group 为单位进行实时统计的读请求 Read Request Unit 消耗信息。`total` 为当前所有 Resource Group 消耗的 Read Request Unit 之和。
- RRU Per Query:平均每个 SQL 语句消耗的 Read Request Unit 数量。计算方法是将前述 Read Request Unit 监控指标除以当前每秒执行的 SQL 语句数量。
- WRU:以 Resource Group 为单位进行实时统计的写请求 Write Request Unit 消耗信息。`total` 为当前所有 Resource Group 消耗的 Write Request Unit 之和。
- WRU Per Query:平均每个 SQL 语句消耗的 Write Request Unit 数量。计算方法是将前述 Write Request Unit 监控指标除以当前每秒执行的 SQL 语句数量。
BornChanger marked this conversation as resolved.
Show resolved Hide resolved

## 资源相关指标

- KV Request Count:以 Resource Group 为单位进行实时统计的 KV 请求数量,区分了读和写两种类型。`total` 为当前所有 Resource Group 涉及的 KV 请求数量之和。
- KV Request Count Per Query:平均每个 SQL 语句涉及的读写 KV 请求数量。计算方法是将前述 KV Request Count 监控指标除以当前每秒执行的 SQL 语句数量。
- Bytes Read:以 Resource Group 为单位进行实时统计的读取数据量。`total` 为当前所有 Resource Group 读取数据量之和。
- Bytes Read Per Query:平均每个 SQL 语句的读取数据量。将前述 Bytes Read 监控指标除以当前每秒执行的 SQL 语句数量。
- Bytes Written:以 Resource Group 为单位进行实时统计的写入数据量。`total` 为当前所有 Resource Group 写入数据量之和。
- Bytes Written Per Query:平均每个 SQL 语句的写入数据量。计算方法是将前述 Bytes Written 监控指标除以当前每秒执行的 SQL 语句数量。
- KV CPU Time:以 Resource Group 为单位进行实时统计的 KV 层 CPU 时间消耗。`total` 为当前所有 Resource Group 消耗 KV 层 CPU 时间之和。
- KV CPU Time Per Query:平均每个 SQL 语句的 KV 层 CPU 时间消耗之和。计算方法是将前述 KV CPU Time 监控指标除以当前每秒执行的 SQL 语句数量。
- SQL CPU Time:以 Resource Group 为单位进行实时统计的 SQL 层 CPU 时间消耗。`total` 为当前所有 Resource Group 消耗 SQL 层 CPU 时间之和。
- SQL CPU Time Per Query:平均每个 SQL 语句的 SQL 层 CPU 时间消耗之和。计算方法是将前述 SQL CPU Time 监控除以当前每秒执行的 SQL 语句数量。
3 changes: 3 additions & 0 deletions grafana-tikv-dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ aliases: ['/docs-cn/dev/grafana-tikv-dashboard/','/docs-cn/dev/reference/key-mon
- Average gRPC message duration:gRPC 请求平均的执行时间
- gRPC batch size:TiDB 与 TiKV 之间 grpc 请求的 batch 大小
- raft message batch size:TiKV 与 TiKV 之间 raft 消息的 batch 大小
- gRPC request sources QPS: 不同 gRPC 请求来源的速度
- gRPC request sources duration: 不同 gRPC 请求来源的执行总时间
- gRPC resource group QPS: 不同 resource group 的 gRPC 请求速度

### Thread CPU

Expand Down
83 changes: 45 additions & 38 deletions information-schema/information-schema-processlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ aliases: ['/docs-cn/dev/information-schema/information-schema-processlist/']
* `DIGEST` 列:显示 SQL 语句的 digest。
* `MEM` 列:显示正在处理的请求已使用的内存,单位是 byte。
* `DISK` 列:显示磁盘空间使用情况,单位是 byte。
* `TxnStart`列:显示事务的开始时间
* `TxnStart`列:显示事务的开始时间。
* `RESOURCE_GROUP`列:显示对应的资源组名称。

{{< copyable "sql" >}}

Expand All @@ -23,23 +24,24 @@ DESC processlist;
```

```sql
+----------+---------------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+------+---------+-------+
| ID | bigint(21) unsigned | NO | | 0 | |
| USER | varchar(16) | NO | | | |
| HOST | varchar(64) | NO | | | |
| DB | varchar(64) | YES | | NULL | |
| COMMAND | varchar(16) | NO | | | |
| TIME | int(7) | NO | | 0 | |
| STATE | varchar(7) | YES | | NULL | |
| INFO | longtext | YES | | NULL | |
| DIGEST | varchar(64) | YES | | | |
| MEM | bigint(21) unsigned | YES | | NULL | |
| DISK | bigint(21) unsigned | YES | | NULL | |
| TxnStart | varchar(64) | NO | | | |
+----------+---------------------+------+------+---------+-------+
12 rows in set (0.00 sec)
+---------------------+---------------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+---------------------+------+------+---------+-------+
| ID | bigint(21) unsigned | NO | | 0 | |
| USER | varchar(16) | NO | | | |
| HOST | varchar(64) | NO | | | |
| DB | varchar(64) | YES | | NULL | |
| COMMAND | varchar(16) | NO | | | |
| TIME | int(7) | NO | | 0 | |
| STATE | varchar(7) | YES | | NULL | |
| INFO | longtext | YES | | NULL | |
| DIGEST | varchar(64) | YES | | | |
| MEM | bigint(21) unsigned | YES | | NULL | |
| DISK | bigint(21) unsigned | YES | | NULL | |
| TxnStart | varchar(64) | NO | | | |
| RESOURCE_GROUP | varchar(32) | NO | | | |
+---------------------+---------------------+------+------+---------+-------+
13 rows in set (0.00 sec)
```

{{< copyable "sql" >}}
Expand All @@ -50,16 +52,19 @@ SELECT * FROM processlist\G

```sql
*************************** 1. row ***************************
ID: 16
USER: root
HOST: 127.0.0.1
DB: information_schema
COMMAND: Query
TIME: 0
STATE: autocommit
INFO: SELECT * FROM processlist
MEM: 0
TxnStart:
ID: 2300033189772525975
USER: root
HOST: 127.0.0.1:51289
DB: NULL
COMMAND: Query
TIME: 0
STATE: autocommit
INFO: SELECT * FROM processlist
DIGEST: dbfaa16980ec628011029f0aaf0d160f4b040885240dfc567bf760d96d374f7e
MEM: 0
DISK: 0
TxnStart:
RESOURCE_GROUP: rg1
1 row in set (0.00 sec)
```

Expand All @@ -76,7 +81,8 @@ TxnStart:
* `DIGEST` 列:SQL 语句的 digest。
* `MEM` 列:正在处理的请求已使用的内存,单位是 byte。
* `DISK` 列:磁盘空间使用情况,单位是 byte。
* `TxnStart`列:显示事务的开始时间
* `TxnStart`列:显示事务的开始时间。
* `RESOURCE_GROUP`列:显示对应的资源组名称。

## CLUSTER_PROCESSLIST

Expand All @@ -89,13 +95,14 @@ SELECT * FROM cluster_processlist;
```

```sql
+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+
| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart |
+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+
| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) |
| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) |
| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) |
| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) |
| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) |
+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+
+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+
| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP |
+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+

| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | default |
| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | rg1 |
| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | rg2 |
| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | default |
| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | default |
+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+
```
55 changes: 55 additions & 0 deletions information-schema/information-schema-resource-groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
title: RESOURCE_GROUPS
summary: 了解 information_schema 表 `RESOURCE_GROUPS`。
---

hfxsd marked this conversation as resolved.
Show resolved Hide resolved
# RESOURCE_GROUPS

> **警告:**
>
> 资源管控是 TiDB 在 v6.6.0 中引入的实验特性,其语法或者行为表现在 GA 前可能会发生变化。
`RESOURCE_GROUPS` 表展示所有资源组 (resource group) 的信息,见[使用资源管控 (Resource Control) 实现资源隔离](/tidb-resource-control.md)

```sql
USE information_schema;
DESC resource_groups;
```

```sql
+------------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+------+---------+-------+
| NAME | varchar(32) | NO | | NULL | |
| RU_PER_SEC | bigint(21) | YES | | NULL | |
| BURSTABLE | varchar(3) | YES | | NULL | |
+------------+-------------+------+------+---------+-------+
3 rows in set (0.00 sec)
```

## 示例

BornChanger marked this conversation as resolved.
Show resolved Hide resolved
```sql
mysql> CREATE RESOURCE GROUP rg1 RU_PER_SEC=1000; -- 创建资源组 rg1
Query OK, 0 rows affected (0.34 sec)
mysql> SHOW CREATE RESOURCE GROUP rg1; -- 显示 rg1 资源组的定义
+----------------+---------------------------------------------+
| Resource_Group | Create Resource Group |
+----------------+---------------------------------------------+
| rg1 | CREATE RESOURCE GROUP `rg1` RU_PER_SEC=1000 |
+----------------+---------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1';
+------+------------+-----------+
| NAME | RU_PER_SEC | BURSTABLE |
+------+------------+-----------+
| rg1 | 1000 | NO |
+------+------------+-----------+
1 row in set (0.00 sec)
```

`RESOURCE_GROUPS` 表中列的含义如下:

* `NAME`:资源组名称。
* `RU_PER_SEC`:资源组的回填速度,单位为每秒回填的 [Request Unit (RU)](/tidb-resource-control.md#什么是-request-unit-ru) 数量。
* `BURSTABLE`:是否允许此资源组超额使用剩余的系统资源。
8 changes: 8 additions & 0 deletions mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,11 @@ TiDB 不支持 MySQL 中标记为弃用的功能,包括:

* 指定浮点类型的精度。MySQL 8.0 [弃用](https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html)了此功能,建议改用 `DECIMAL` 类型。
* `ZEROFILL` 属性。MySQL 8.0 [弃用](https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html)了此功能,建议在业务应用中填充数字值。

### `CREATE RESOURCE GROUP`,`DROP RESOURCE GROUP` 和 `ALTER RESOURCE GROUP`

TiDB 资源组创建与修改语句的语法与 MySQL 官方不同,详情参见:

- [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md)
- [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md)
- [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md)
12 changes: 12 additions & 0 deletions privilege-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,18 @@ SELECT * FROM INFORMATION_SCHEMA.USER_PRIVILEGES WHERE grantee = "'root'@'%'";

使用 `KILL` 终止其他用户的会话需要拥有 `SUPER` 或者 `CONNECTION_ADMIN` 权限。

### CREATE RESOURCE GROUP

需要拥有 `SUPER` 或者 `RESOURCE_GROUP_ADMIN` 权限。

### ALTER RESOURCE GROUP

需要拥有 `SUPER` 或者 `RESOURCE_GROUP_ADMIN` 权限。

### DROP RESOURCE GROUP

需要拥有 `SUPER` 或者 `RESOURCE_GROUP_ADMIN` 权限。

hfxsd marked this conversation as resolved.
Show resolved Hide resolved
## 权限系统的实现

### 授权表
Expand Down
Loading