From 948974ff36b1b2c2d43994c9ab5d825b247670b5 Mon Sep 17 00:00:00 2001 From: feiniaofeiafei Date: Mon, 29 Jun 2026 15:00:53 +0800 Subject: [PATCH 1/2] remove cn and en --- .../workload-management/sql-blocking.md | 34 +--------- .../CREATE-WORKLOAD-POLICY.md | 1 - .../workload-management/sql-blocking.md | 34 +--------- .../CREATE-WORKLOAD-POLICY.md | 3 +- .../workload-management/sql-blocking.md | 36 +--------- .../CREATE-WORKLOAD-POLICY.md | 3 +- .../workload-management/sql-blocking.md | 34 +--------- .../CREATE-WORKLOAD-POLICY.md | 3 +- .../workload-management/sql-blocking.md | 34 +--------- .../CREATE-WORKLOAD-POLICY.md | 3 +- .../workload-management/sql-blocking.md | 36 +--------- .../CREATE-WORKLOAD-POLICY.md | 5 +- .../workload-management/sql-blocking.md | 34 +--------- .../CREATE-WORKLOAD-POLICY.md | 68 +++++++++++-------- .../workload-management/sql-blocking.md | 34 +--------- .../CREATE-WORKLOAD-POLICY.md | 1 - 16 files changed, 55 insertions(+), 308 deletions(-) diff --git a/docs/admin-manual/workload-management/sql-blocking.md b/docs/admin-manual/workload-management/sql-blocking.md index c0f7a729c9926..dde5711f01271 100644 --- a/docs/admin-manual/workload-management/sql-blocking.md +++ b/docs/admin-manual/workload-management/sql-blocking.md @@ -221,7 +221,6 @@ Conditions specify when the policy is triggered. Multiple conditions are separat | Condition | Description | |-----------|------| -| `username` | The username carried by the query. Only triggers the `set_session_variable` Action on the FE | | `be_scan_rows` | The number of rows scanned by a SQL within a single BE process. Cumulative value under concurrent execution | | `be_scan_bytes` | The number of bytes scanned by a SQL within a single BE process. Cumulative value under concurrent execution (unit: bytes) | | `query_time` | The execution time of a SQL on a single BE process (unit: milliseconds) | @@ -229,12 +228,11 @@ Conditions specify when the policy is triggered. Multiple conditions are separat #### Actions -Actions specify what to do when the conditions are triggered. Currently, a Policy can define only one Action (except for `set_session_variable`). +Actions specify what to do when the conditions are triggered. Currently, a Policy can define only one Action. | Action | Description | |--------|------| | `cancel_query` | Cancel the query | -| `set_session_variable` | Execute a set session variable statement. The same Policy can include multiple of these options. Currently, this is only triggered on the FE by the `username` Condition | #### Policy Properties @@ -302,38 +300,8 @@ MySQL [hits]> SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload policy,id:12345 ``` -#### Example 2: Automatically Adjust User Session Variables - -Workload Policy can automatically modify session variables for a specific user, for example, lowering concurrency to reduce resource consumption: - -```sql --- Check the current concurrency parameter for the admin user -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a policy: set the concurrency parameter for the admin user to 1 -CREATE WORKLOAD POLICY test_set_var_policy -CONDITIONS(username='admin') -ACTIONS(set_session_variable 'parallel_fragment_exec_instance_num=1'); - --- Check again later, the parameter has taken effect -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - ### Notes -- **FE/BE side isolation**: The Condition and Action of the same Policy must belong to the same side (FE or BE). For example, `set_session_variable` (FE side) and `cancel_query` (BE side) cannot be configured in the same Policy. The same applies to `username` (FE side) and `be_scan_rows` (BE side). - **Asynchronous execution latency**: Policies are checked by an asynchronous thread every 500 ms, so policy enforcement has some lag. Queries that run for a very short time may complete before the check is triggered and bypass the policy. - **Priority mechanism**: A query may match multiple Policies, but only the one with the highest priority (largest `priority` value) takes effect. - **Modification limit**: Currently, directly modifying the Action and Condition of an existing Policy is not supported. Delete the Policy and recreate it. diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index d32978c4d144c..13434b21efcb4 100644 --- a/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -29,7 +29,6 @@ CONDITIONS() ACTIONS() - query_be_memory_bytes: Supported since version 2.1.5. The memory usage of a SQL within a single BE process. If the SQL is executed with multiple concurrencies on the BE, this is the cumulative value of the concurrent executions, in bytes. 3. `` - - set_session_variable: This action executes a `set_session_variable` statement. A single Policy may contain multiple `set_session_variable` actions, allowing one Policy to execute multiple session-variable updates. - cancel_query: Cancel the query. ## Optional Parameters diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md index 08ba3258efc22..fd1c7ac8c0f70 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md @@ -221,7 +221,6 @@ Conditions 表示策略的触发条件,多个条件之间以逗号 `,` 分隔 | Condition | 说明 | |-----------|------| -| `username` | 查询携带的用户名,只会在 FE 触发 `set_session_variable` Action | | `be_scan_rows` | 一个 SQL 在单个 BE 进程内扫描的行数,多并发执行时为累加值 | | `be_scan_bytes` | 一个 SQL 在单个 BE 进程内扫描的字节数,多并发执行时为累加值(单位:字节) | | `query_time` | 一个 SQL 在单个 BE 进程上的运行时间(单位:毫秒) | @@ -229,12 +228,11 @@ Conditions 表示策略的触发条件,多个条件之间以逗号 `,` 分隔 #### 执行动作(Actions) -Actions 表示条件触发时采取的动作。目前一个 Policy 只能定义一个 Action(`set_session_variable` 除外)。 +Actions 表示条件触发时采取的动作。目前一个 Policy 只能定义一个 Action。 | Action | 说明 | |--------|------| | `cancel_query` | 取消查询 | -| `set_session_variable` | 执行 set session variable 语句;同一个 Policy 可包含多个该选项,目前只会在 FE 由 `username` Condition 触发 | #### 策略属性(Properties) @@ -302,38 +300,8 @@ MySQL [hits]> SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload policy,id:12345 ``` -#### 示例二:自动调整用户 Session 变量 - -通过 Workload Policy 可自动修改特定用户的 session 变量,例如降低其并发度以减少资源占用: - -```sql --- 查看 admin 用户当前并发参数 -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- 创建策略:将 admin 用户的并发参数调整为 1 -CREATE WORKLOAD POLICY test_set_var_policy -CONDITIONS(username='admin') -ACTIONS(set_session_variable 'parallel_fragment_exec_instance_num=1'); - --- 稍后再次查看,参数已生效 -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - ### 注意事项 -- **FE/BE 侧隔离**:同一个 Policy 的 Condition 和 Action 必须属于同一侧(FE 或 BE)。例如,`set_session_variable`(FE 侧)和 `cancel_query`(BE 侧)不能配置在同一 Policy 中;`username`(FE 侧)和 `be_scan_rows`(BE 侧)同理。 - **异步执行延迟**:Policy 由异步线程每 500 ms 执行一次检查,策略生效存在一定滞后。运行时间极短的查询可能会在检查触发前已完成,从而绕过策略。 - **优先级机制**:一个查询可能匹配多个 Policy,但只有优先级最高(`priority` 值最大)的 Policy 会生效。 - **修改限制**:目前不支持直接修改已有 Policy 的 Action 和 Condition,需删除后重新创建。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index 71647b128f066..2ff6f955da2bf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -29,7 +29,6 @@ CONDITIONS() ACTIONS() - query_be_memory_bytes,从 2.1.5 版本开始支持。一个 SQL 在单个 BE 进程内使用的内存用量,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 3. `` - - set_session_variable,这个 Action 可以执行一条 `set_session_variable` 的语句。同一个 Policy 可以有多个 `set_session_variable`,也就是说一个 Policy 可以执行多个修改 session 变量的语句。 - cancel_query,取消查询。 ## 可选参数 @@ -70,4 +69,4 @@ CONDITIONS() ACTIONS() ```Java create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('workload_group'='compute_group_a.wg1') - ``` \ No newline at end of file + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md index 188c5e4078277..91273130eaff5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md @@ -235,18 +235,16 @@ properties('enabled'='true'); | Conditions | 说明 | |-----------------------|---------------------------------------------------------------------| -| username | 查询携带的用户名,只会在 FE 触发 set_session_variable Action | | be_scan_rows | 一个 SQL 在单个 BE 进程内 scan 的行数,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值。 | | be_scan_bytes | 一个 SQL 在单个 BE 进程内 scan 的字节数,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 | | query_time | 一个 SQL 在单个 BE 进程上的运行时间,时间单位是毫秒。 | | query_be_memory_bytes | 一个 SQL 在单个 BE 进程内使用的内存用量,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 | -- Action 表示条件触发时采取的动作,目前一个 Policy 只能定义一个 Action(除 set_session_variable)。在上例中,cancel_query 表示取消查询;目前支持的 Actions 有: +- Action 表示条件触发时采取的动作,目前一个 Policy 只能定义一个 Action。在上例中,cancel_query 表示取消查询;目前支持的 Actions 有: | Actions | 说明 | |-----------------------|------------------------------------------------------------------------------------------------------| | cancel_query | 取消查询。 | -| set_session_variable | 触发 set session variable 语句。同一个 policy 可以有多个 set_session_variable 选项,目前只会在 FE 由 username Condition 触发 | - Properties,定义了当前 Policy 的属性,包括是否启用和优先级。 @@ -268,7 +266,6 @@ properties('workload_group'='normal') ``` ### 注意事项 -- 同一个 Policy 的 Condition 和 Action 要么都是 FE 的,要么都是 BE 的,比如 set_session_variable 和 cancel_query 无法配置到同一个 Policy 中。Condition be_scan_rows 和 Condition username 无法配置到同一个 Policy 中。 - 由于目前的 Policy 是异步线程以固定时间间隔执行的,因此策略的生效存在一定的滞后性。比如用户配置了 scan 行数大于 100 万就取消查询的策略,如果此时集群资源比较空闲,那么有可能在取消策略生效之前查询就已经结束了。目前这个时间间隔为 500ms,这意味着运行时间过短的查询可能会绕过策略的检查。 - 当前支持的负载类型包括 select/insert select/stream load/broker load/routine load。 - 一个查询可能匹配到多个 Policy,但是只有优先级最高的 Policy 会生效。 @@ -276,35 +273,7 @@ properties('workload_group'='normal') ### Workload Policy 效果演示 -#### 1 session 变量修改测试 -尝试修改 Admin 账户的 session 变量中的并发相关的参数 - -```sql -// 登录 admin账户查看并发参数 -mySQL [(none)]>show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - -// 创建修改admin账户并发参数的Policy -create workload Policy test_set_var_Policy -Conditions(username='admin') -Actions(set_session_variable 'parallel_fragment_exec_instance_num=1') - -// 过段时间后再次查看admin账户的参数 -mySQL [(none)]>show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - -#### 2 大查询熔断测试 +#### 大查询熔断测试 测试对运行时间超过 3s 的查询进行熔断,以下是一个 ckbench 的 q29 运行成功时的审计日志,可以看到这个 SQL 跑完需要 4.5s 的时间 ```sql @@ -339,4 +308,3 @@ Actions(cancel_query) mySQL [hits]>SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25; ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload Policy,id:12345 ``` - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index c6cef5e5e818f..de197a06762a6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -29,7 +29,6 @@ CONDITIONS() ACTIONS() - query_be_memory_bytes,从 2.1.5 版本开始支持。一个 SQL 在单个 BE 进程内使用的内存用量,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 3. `` - - set_session_variable,这个 Action 可以执行一条 `set_session_variable` 的语句。同一个 Policy 可以有多个 `set_session_variable`,也就是说一个 Policy 可以执行多个修改 session 变量的语句。 - cancel_query,取消查询。 ## 可选参数 @@ -55,4 +54,4 @@ CONDITIONS() ACTIONS() ```Java create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') - ``` \ No newline at end of file + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md index 129ed29488ab9..413587104f158 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md @@ -189,7 +189,6 @@ Conditions 表示策略的触发条件,多个 Condition 之间以逗号 `,` | Condition | 说明 | |-----------------------|-----------------------------------------------------------------------------------------------| -| username | 查询携带的用户名,只会在 FE 触发 set_session_variable Action | | be_scan_rows | 一个 SQL 在单个 BE 进程内 scan 的行数,多并发执行时为累加值 | | be_scan_bytes | 一个 SQL 在单个 BE 进程内 scan 的字节数,多并发执行时为累加值,单位是字节 | | query_time | 一个 SQL 在单个 BE 进程上的运行时间,单位是毫秒 | @@ -197,12 +196,11 @@ Conditions 表示策略的触发条件,多个 Condition 之间以逗号 `,` #### 执行动作(Actions) -Actions 表示条件触发时采取的动作,目前一个 Policy 只能定义一个 Action(set_session_variable 除外)。 +Actions 表示条件触发时采取的动作,目前一个 Policy 只能定义一个 Action。 | Action | 说明 | |----------------------|------------------------------------------------------------------------------------------------------------| | cancel_query | 取消查询 | -| set_session_variable | 触发 set session variable 语句。同一个 Policy 可以有多个 set_session_variable 选项,目前只会在 FE 由 username Condition 触发 | #### 策略属性(Properties) @@ -264,38 +262,8 @@ MySQL [hits]> SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload policy,id:12345 ``` -#### 示例二:修改用户 session 变量 - -通过 Workload Policy 可以自动修改特定用户的 session 变量,例如调整并发参数: - -```sql --- 登录 admin 账户查看并发参数 -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- 创建修改 admin 账户并发参数的 Policy -CREATE WORKLOAD POLICY test_set_var_policy -CONDITIONS(username='admin') -ACTIONS(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- 过段时间后再次查看 admin 账户的参数 -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - ### 注意事项 -- 同一个 Policy 的 Condition 和 Action 必须属于同一侧(FE 或 BE)。例如,set_session_variable 和 cancel_query 无法配置到同一个 Policy 中;Condition be_scan_rows 和 Condition username 也无法配置到同一个 Policy 中。 - Policy 由异步线程以固定时间间隔(当前为 500 ms)执行,因此策略生效存在一定滞后性。运行时间过短的查询可能会绕过策略检查。 - 一个查询可能匹配到多个 Policy,但只有优先级最高的 Policy 会生效。 - 目前不支持直接修改 Action 和 Condition,只能通过删除后重新创建的方式修改。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index c6cef5e5e818f..de197a06762a6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -29,7 +29,6 @@ CONDITIONS() ACTIONS() - query_be_memory_bytes,从 2.1.5 版本开始支持。一个 SQL 在单个 BE 进程内使用的内存用量,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 3. `` - - set_session_variable,这个 Action 可以执行一条 `set_session_variable` 的语句。同一个 Policy 可以有多个 `set_session_variable`,也就是说一个 Policy 可以执行多个修改 session 变量的语句。 - cancel_query,取消查询。 ## 可选参数 @@ -55,4 +54,4 @@ CONDITIONS() ACTIONS() ```Java create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') - ``` \ No newline at end of file + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md index 626b91a492b63..570d32de409b0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md @@ -238,7 +238,6 @@ Conditions 表示策略的触发条件,多个条件之间以逗号 `,` 分隔 | Condition | 说明 | |-----------|------| -| `username` | 查询携带的用户名,只会在 FE 触发 `set_session_variable` Action | | `be_scan_rows` | 一个 SQL 在单个 BE 进程内扫描的行数,多并发执行时为累加值 | | `be_scan_bytes` | 一个 SQL 在单个 BE 进程内扫描的字节数,多并发执行时为累加值(单位:字节) | | `query_time` | 一个 SQL 在单个 BE 进程上的运行时间(单位:毫秒) | @@ -246,12 +245,11 @@ Conditions 表示策略的触发条件,多个条件之间以逗号 `,` 分隔 #### 执行动作(Actions) -Actions 表示条件触发时采取的动作。目前一个 Policy 只能定义一个 Action(`set_session_variable` 除外)。 +Actions 表示条件触发时采取的动作。目前一个 Policy 只能定义一个 Action。 | Action | 说明 | |--------|------| | `cancel_query` | 取消查询 | -| `set_session_variable` | 执行 set session variable 语句;同一个 Policy 可包含多个该选项,目前只会在 FE 由 `username` Condition 触发 | #### 策略属性(Properties) @@ -319,38 +317,8 @@ MySQL [hits]> SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload policy,id:12345 ``` -#### 示例二:自动调整用户 Session 变量 - -通过 Workload Policy 可自动修改特定用户的 session 变量,例如降低其并发度以减少资源占用: - -```sql --- 查看 admin 用户当前并发参数 -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- 创建策略:将 admin 用户的并发参数调整为 1 -CREATE WORKLOAD POLICY test_set_var_policy -CONDITIONS(username='admin') -ACTIONS(set_session_variable 'parallel_fragment_exec_instance_num=1'); - --- 稍后再次查看,参数已生效 -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - ### 注意事项 -- **FE/BE 侧隔离**:同一个 Policy 的 Condition 和 Action 必须属于同一侧(FE 或 BE)。例如,`set_session_variable`(FE 侧)和 `cancel_query`(BE 侧)不能配置在同一 Policy 中;`username`(FE 侧)和 `be_scan_rows`(BE 侧)同理。 - **异步执行延迟**:Policy 由异步线程每 500 ms 执行一次检查,策略生效存在一定滞后。运行时间极短的查询可能会在检查触发前已完成,从而绕过策略。 - **优先级机制**:一个查询可能匹配多个 Policy,但只有优先级最高(`priority` 值最大)的 Policy 会生效。 - **修改限制**:目前不支持直接修改已有 Policy 的 Action 和 Condition,需删除后重新创建。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index 71647b128f066..2ff6f955da2bf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -29,7 +29,6 @@ CONDITIONS() ACTIONS() - query_be_memory_bytes,从 2.1.5 版本开始支持。一个 SQL 在单个 BE 进程内使用的内存用量,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 3. `` - - set_session_variable,这个 Action 可以执行一条 `set_session_variable` 的语句。同一个 Policy 可以有多个 `set_session_variable`,也就是说一个 Policy 可以执行多个修改 session 变量的语句。 - cancel_query,取消查询。 ## 可选参数 @@ -70,4 +69,4 @@ CONDITIONS() ACTIONS() ```Java create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('workload_group'='compute_group_a.wg1') - ``` \ No newline at end of file + ``` diff --git a/versioned_docs/version-2.1/admin-manual/workload-management/sql-blocking.md b/versioned_docs/version-2.1/admin-manual/workload-management/sql-blocking.md index ff93fb5ee0bac..b54fc297d11fc 100644 --- a/versioned_docs/version-2.1/admin-manual/workload-management/sql-blocking.md +++ b/versioned_docs/version-2.1/admin-manual/workload-management/sql-blocking.md @@ -236,18 +236,16 @@ When creating a Workload Policy, the following must be specified: | Conditions | Description | |-----------------------|-------------------------------------------------------------------------------------------------------------| -| username | The username carried by the query, only triggers the `set_session_variable` Action in FE. | | be_scan_rows | The number of rows scanned by a SQL in a single BE process. If the SQL is executed concurrently on BE, it is the cumulative value of multiple concurrent executions. | | be_scan_bytes | The number of bytes scanned by a SQL in a single BE process. If the SQL is executed concurrently on BE, it is the cumulative value of multiple concurrent executions, in bytes. | | query_time | The runtime of a SQL in a single BE process, in milliseconds. | | query_be_memory_bytes | The memory usage of a SQL in a single BE process. If the SQL is executed concurrently on BE, it is the cumulative value of multiple concurrent executions, in bytes. | -- **Action** represents the action taken when the condition is triggered. Currently, a Policy can only define one Action (except for `set_session_variable`). In the example above, `cancel_query` indicates cancelling the query. Currently supported Actions are: +- **Action** represents the action taken when the condition is triggered. Currently, a Policy can only define one Action. In the example above, `cancel_query` indicates cancelling the query. Currently supported Actions are: | Actions | Description | |------------------------|------------------------------------------------------------------------------------------------------------------| | cancel_query | Cancel the query. | -| set_session_variable | Triggers the `set session variable` statement. A single policy can have multiple `set_session_variable` options, currently only triggered in FE by the `username` Condition. | - **Properties** define the attributes of the current Policy, including whether it is enabled and its priority. @@ -269,7 +267,6 @@ properties('workload_group'='normal') ``` ### Important Notes -- The Conditions and Actions of the same Policy must either both be FE or both be BE. For example, `set_session_variable` and `cancel_query` cannot be configured within the same Policy. Conditions `be_scan_rows` and `username` cannot be configured within the same Policy. - Currently, Policies are executed by asynchronous threads at fixed time intervals, which introduces a certain latency in policy enforcement. For example, if a user configures a policy to cancel a query when the number of scanned rows exceeds 1,000,000, and the cluster resources are relatively idle at that time, the query may finish before the cancellation policy takes effect. The current interval is 500ms, meaning that queries with run times shorter than this interval may bypass the policy check. - Currently supported load types include select/insert, select/stream load, broker load, and routine load. - A single query may match multiple Policies, but only the Policy with the highest priority will take effect. @@ -277,35 +274,7 @@ properties('workload_group'='normal') ### Workload Policy Demonstration -#### 1. Session Variable Modification Test -Attempt to modify concurrency-related parameters in the session variables of the Admin account. - -```sql --- log on admin to check variables -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a Policy to modify the concurrency parameters of the admin account. -create workload Policy test_set_var_Policy -Conditions(username='admin') -Actions(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- After some time, check the admin account's parameters again. -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - -#### 2. Big Query Circuit Breaker Test +#### Big Query Circuit Breaker Test Test to circuit break queries that run longer than 3s. Below is an audit log of a successful run of ckbench's q29, showing that this SQL took 4.5s to complete. @@ -342,4 +311,3 @@ Upon re-executing the SQL, you can see that the SQL execution will directly repo mySQL [hits]>SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25; ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload Policy,id:12345 ``` - diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/versioned_docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index f83b33143ad31..02e7b08c881fd 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -35,8 +35,7 @@ The name of the Workload Policy. `` -1. **set_session_variable**: This action executes a set session variable statement. Multiple **set_session_variable** actions can be specified in the same policy, allowing multiple session variable modification statements to be executed within one policy. -2. **cancel_query**: Cancels the query. +1. **cancel_query**: Cancels the query. ### Optional Parameters @@ -62,4 +61,4 @@ Requires at least `ADMIN_PRIV` permissions. ```Java create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') - ``` \ No newline at end of file + ``` diff --git a/versioned_docs/version-3.x/admin-manual/workload-management/sql-blocking.md b/versioned_docs/version-3.x/admin-manual/workload-management/sql-blocking.md index bb42e1c8a9892..dbf42ae0e9053 100644 --- a/versioned_docs/version-3.x/admin-manual/workload-management/sql-blocking.md +++ b/versioned_docs/version-3.x/admin-manual/workload-management/sql-blocking.md @@ -189,7 +189,6 @@ Conditions represent the policy trigger conditions. Multiple Conditions are sepa | Condition | Description | |-----------------------|------------------------------------------------------------------------------------------------------| -| username | The username carried by the query; only triggers the set_session_variable Action in FE | | be_scan_rows | Number of rows scanned by a SQL in a single BE process; cumulative value when executed concurrently | | be_scan_bytes | Number of bytes scanned by a SQL in a single BE process; cumulative value when executed concurrently, in bytes | | query_time | Runtime of a SQL in a single BE process, in milliseconds | @@ -197,12 +196,11 @@ Conditions represent the policy trigger conditions. Multiple Conditions are sepa #### Actions -Actions represent the action taken when the condition is triggered. Currently, a Policy can only define one Action (except for set_session_variable). +Actions represent the action taken when the condition is triggered. Currently, a Policy can only define one Action. | Action | Description | |----------------------|-----------------------------------------------------------------------------------------------------------------| | cancel_query | Cancel the query | -| set_session_variable | Triggers a set session variable statement. A single Policy can have multiple set_session_variable options; currently only triggered in FE by the username Condition | #### Properties @@ -264,38 +262,8 @@ MySQL [hits]> SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload policy,id:12345 ``` -#### Example 2: Modifying User Session Variables - -Workload Policy can automatically modify session variables for specific users, for example, adjusting concurrency parameters: - -```sql --- Log in to admin account and check concurrency parameters -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a Policy to modify the concurrency parameters of the admin account -CREATE WORKLOAD POLICY test_set_var_policy -CONDITIONS(username='admin') -ACTIONS(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- After some time, check the admin account's parameters again -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - ### Important Notes -- The Conditions and Actions of the same Policy must belong to the same side (FE or BE). For example, set_session_variable and cancel_query cannot be configured within the same Policy; Condition be_scan_rows and Condition username also cannot be configured within the same Policy. - Policies are executed by asynchronous threads at fixed time intervals (currently 500 ms), so there is a certain latency in policy enforcement. Queries with very short run times may bypass the policy check. - A single query may match multiple Policies, but only the Policy with the highest priority will take effect. - Modifications to Actions and Conditions are currently not supported; they can only be modified by deleting and recreating them. diff --git a/versioned_docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/versioned_docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index 72674d56f15c1..f99d71c9074bc 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/versioned_docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -1,54 +1,64 @@ --- { - "title": "CREATE WORKLOAD GROUP | Compute Management", - "language": "en", - "description": "This statement is used to create a workload group. Workload groups enable the isolation of cpu resources and memory resources on a single be.", - "sidebar_label": "CREATE WORKLOAD GROUP" + "title": "CREATE WORKLOAD POLICY", + "language": "en", + "description": "Create a Workload Policy to execute corresponding actions on a query when it meets certain conditions." } --- -# CREATE WORKLOAD GROUP - ## Description -This statement is used to create a workload group. Workload groups enable the isolation of cpu resources and memory resources on a single be. +Create a Workload Policy to execute corresponding actions on a query when it meets certain conditions. + + +## Syntax -grammar: ```sql -CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" -PROPERTIES ( - property_list -); +CREATE WORKLOAD POLICY [ IF NOT EXISTS ] +CONDITIONS() ACTIONS() +[ PROPERTIES () ] ``` +### Required Parameters + +`` + +The name of the Workload Policy. + + + +1. **be_scan_rows**: The number of rows scanned by an SQL query within a single BE process. If the SQL query is executed concurrently on multiple BEs, it is the cumulative value of these concurrent executions. +2. **be_scan_bytes**: The number of bytes scanned by an SQL query within a single BE process. If the SQL query is executed concurrently on multiple BEs, it is the cumulative value of these concurrent executions (in bytes). +3. **query_time**: The execution time of an SQL query on a single BE process, in milliseconds. +4. **query_be_memory_bytes** (supported from version 2.1.5): The amount of memory used by an SQL query within a single BE process. If the SQL query is executed concurrently on multiple BEs, it is the cumulative value of these concurrent executions (in bytes). -illustrate: -Properties supported by property_list: +`` -* cpu_share: Required, used to set how much cpu time the workload group can acquire, which can achieve soft isolation of cpu resources. cpu_share is a relative value indicating the weight of cpu resources available to the running workload group. For example, if a user creates 3 workload groups rg-a, rg-b and rg-c with cpu_share of 10, 30 and 40 respectively, and at a certain moment rg-a and rg-b are running tasks while rg-c has no tasks, then rg-a can get (10 / (10 + 30)) = 25% of the cpu resources while workload group rg-b can get 75% of the cpu resources. If the system has only one workload group running, it gets all the cpu resources regardless of the value of its cpu_share. +1. **cancel_query**: Cancels the query. -* memory_limit: Required, set the percentage of be memory that can be used by the workload group. The absolute value of the workload group memory limit is: `physical_memory * mem_limit * memory_limit`, where mem_limit is a be configuration item. The total memory_limit of all workload groups in the system must not exceed 100%. Workload groups are guaranteed to use the memory_limit for the tasks in the group in most cases. When the workload group memory usage exceeds this limit, tasks in the group with larger memory usage may be canceled to release the excess memory, refer to enable_memory_overcommit. +### Optional Parameters -* enable_memory_overcommit: Optional, enable soft memory isolation for the workload group, default is false. if set to false, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is softly isolated, if the system has free memory resources, the workload group can continue to use system memory after exceeding the memory_limit limit, and when the total system memory is tight, it will cancel several tasks in the group with the largest memory occupation, releasing part of the excess memory to relieve the system memory pressure. It is recommended that when this configuration is enabled for a workload group, the total memory_limit of all workload groups should be less than 100%, and the remaining portion should be used for workload group memory overcommit. -## Example -1. Create a workload group named g1: +1. **enabled**: Takes a value of true or false, with a default value of true. When set to true, the policy is enabled; when set to false, the policy is disabled. +2. **priority**: An integer value ranging from 0 to 100, with a default value of 0. This represents the priority of the policy. The higher the value, the higher the priority. When multiple policies match, the policy with the highest priority is selected. +3. **workload_group**: Currently, a policy can be bound to one workload group, indicating that this policy only applies to a specific workload group. The default is empty, meaning it applies to all queries. - ```sql - create workload group if not exists g1 - properties ( - "cpu_share"="10", - "memory_limit"="30%", - "enable_memory_overcommit"="true" - ); - ``` +### Access Control Requirements -## Keywords +Requires at least `ADMIN_PRIV` permissions. -CREATE, WORKLOAD, GROUP +## Examples +1. Create a new Workload Policy to kill all queries that exceed 3 seconds in query time. + ```Java + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) + ``` +1. Create a new Workload Policy that is not enabled by default. + ```Java + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') + ``` diff --git a/versioned_docs/version-4.x/admin-manual/workload-management/sql-blocking.md b/versioned_docs/version-4.x/admin-manual/workload-management/sql-blocking.md index 2c07945ffe5f2..75a910e369c98 100644 --- a/versioned_docs/version-4.x/admin-manual/workload-management/sql-blocking.md +++ b/versioned_docs/version-4.x/admin-manual/workload-management/sql-blocking.md @@ -238,7 +238,6 @@ Conditions specify when the policy is triggered. Multiple conditions are separat | Condition | Description | |-----------|------| -| `username` | The username carried by the query. Only triggers the `set_session_variable` Action on the FE | | `be_scan_rows` | The number of rows scanned by a SQL within a single BE process. Cumulative value under concurrent execution | | `be_scan_bytes` | The number of bytes scanned by a SQL within a single BE process. Cumulative value under concurrent execution (unit: bytes) | | `query_time` | The execution time of a SQL on a single BE process (unit: milliseconds) | @@ -246,12 +245,11 @@ Conditions specify when the policy is triggered. Multiple conditions are separat #### Actions -Actions specify what to do when the conditions are triggered. Currently, a Policy can define only one Action (except for `set_session_variable`). +Actions specify what to do when the conditions are triggered. Currently, a Policy can define only one Action. | Action | Description | |--------|------| | `cancel_query` | Cancel the query | -| `set_session_variable` | Execute a set session variable statement. The same Policy can include multiple of these options. Currently, this is only triggered on the FE by the `username` Condition | #### Policy Properties @@ -319,38 +317,8 @@ MySQL [hits]> SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\\.)?([^/]+)/.*$', ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[CANCELLED]query cancelled by workload policy,id:12345 ``` -#### Example 2: Automatically Adjust User Session Variables - -Workload Policy can automatically modify session variables for a specific user, for example, lowering concurrency to reduce resource consumption: - -```sql --- Check the current concurrency parameter for the admin user -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a policy: set the concurrency parameter for the admin user to 1 -CREATE WORKLOAD POLICY test_set_var_policy -CONDITIONS(username='admin') -ACTIONS(set_session_variable 'parallel_fragment_exec_instance_num=1'); - --- Check again later, the parameter has taken effect -MySQL [(none)]> show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` - ### Notes -- **FE/BE side isolation**: The Condition and Action of the same Policy must belong to the same side (FE or BE). For example, `set_session_variable` (FE side) and `cancel_query` (BE side) cannot be configured in the same Policy. The same applies to `username` (FE side) and `be_scan_rows` (BE side). - **Asynchronous execution latency**: Policies are checked by an asynchronous thread every 500 ms, so policy enforcement has some lag. Queries that run for a very short time may complete before the check is triggered and bypass the policy. - **Priority mechanism**: A query may match multiple Policies, but only the one with the highest priority (largest `priority` value) takes effect. - **Modification limit**: Currently, directly modifying the Action and Condition of an existing Policy is not supported. Delete the Policy and recreate it. diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/versioned_docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index d32978c4d144c..13434b21efcb4 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -29,7 +29,6 @@ CONDITIONS() ACTIONS() - query_be_memory_bytes: Supported since version 2.1.5. The memory usage of a SQL within a single BE process. If the SQL is executed with multiple concurrencies on the BE, this is the cumulative value of the concurrent executions, in bytes. 3. `` - - set_session_variable: This action executes a `set_session_variable` statement. A single Policy may contain multiple `set_session_variable` actions, allowing one Policy to execute multiple session-variable updates. - cancel_query: Cancel the query. ## Optional Parameters From 7eef1e69408b6674100a25128aaf3c38020a27f5 Mon Sep 17 00:00:00 2001 From: feiniaofeiafei Date: Mon, 29 Jun 2026 15:22:34 +0800 Subject: [PATCH 2/2] add ja --- .../workload-management/sql-blocking.md | 34 +------- .../CREATE-WORKLOAD-POLICY.md | 79 +++++++++++------- .../workload-management/sql-blocking.md | 34 +------- .../CREATE-WORKLOAD-POLICY.md | 3 +- .../workload-management/sql-blocking.md | 34 +------- .../CREATE-WORKLOAD-POLICY.md | 70 +++++++++------- .../workload-management/sql-blocking.md | 34 +------- .../CREATE-WORKLOAD-POLICY.md | 81 ++++++++++++------- 8 files changed, 156 insertions(+), 213 deletions(-) diff --git a/ja-source/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md b/ja-source/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md index e2257f385a931..434f3774d4ca0 100644 --- a/ja-source/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md +++ b/ja-source/docusaurus-plugin-content-docs/current/admin-manual/workload-management/sql-blocking.md @@ -225,18 +225,16 @@ Workload Policyを作成する際は、以下を指定する必要がありま | Conditions | 説明 | |-----------------------|-------------------------------------------------------------------------------------------------------------| -| username | クエリによって運ばれるユーザー名。FEでの`set_session_variable` Actionのみをトリガーします。 | | be_scan_rows | 単一のBEプロセスでSQLがスキャンした行数。SQLがBE上で並行実行される場合、複数の並行実行の累積値です。 | | be_scan_bytes | 単一のBEプロセスでSQLがスキャンしたバイト数。SQLがBE上で並行実行される場合、複数の並行実行の累積値で、バイト単位です。 | | query_time | 単一のBEプロセスでのSQLの実行時間。ミリ秒単位です。 | | query_be_memory_bytes | 単一のBEプロセスでのSQLのメモリ使用量。SQLがBE上で並行実行される場合、複数の並行実行の累積値で、バイト単位です。 | -- **Action**は条件がトリガーされたときに実行されるアクションを表します。現在、Policyは1つのActionのみを定義できます(`set_session_variable`を除く)。上記の例では、`cancel_query`はクエリをキャンセルすることを示します。現在サポートされているActionは以下の通りです: +- **Action**は条件がトリガーされたときに実行されるアクションを表します。現在、Policyは1つのActionのみを定義できます。上記の例では、`cancel_query`はクエリをキャンセルすることを示します。現在サポートされているActionは以下の通りです: | Actions | 説明 | |------------------------|------------------------------------------------------------------------------------------------------------------| | cancel_query | クエリをキャンセルします。 | -| set_session_variable | `set session variable`ステートメントをトリガーします。単一のポリシーは複数の`set_session_variable`オプションを持つことができ、現在は`username` ConditionによってFEでのみトリガーされます。 | - **Properties**は現在のPolicyの属性を定義し、有効かどうかとその優先度を含みます。 @@ -257,7 +255,6 @@ Actions(cancel_query) properties('workload_group'='normal') ``` ### 重要な注意事項 -- 同一のPolicyのConditionsとActionsは、両方ともFEまたは両方ともBEのいずれかである必要があります。例えば、`set_session_variable`と`cancel_query`は同一のPolicy内で設定することはできません。Conditions `be_scan_rows`と`username`は同一のPolicy内で設定することはできません。 - 現在、Policyは固定時間間隔で非同期スレッドによって実行されるため、ポリシー実行に一定の遅延が生じます。例えば、ユーザーがスキャンされた行数が1,000,000を超えた時にクエリをキャンセルするポリシーを設定し、その時点でクラスターリソースが比較的アイドル状態の場合、キャンセルポリシーが有効になる前にクエリが完了する可能性があります。現在の間隔は500msであり、この間隔より短い実行時間のクエリはポリシーチェックをバイパスする可能性があります。 - 現在サポートされているロードタイプには、select/insert、select/stream load、broker load、およびroutine loadが含まれます。 - 単一のクエリは複数のPolicyにマッチする可能性がありますが、最も高い優先度を持つPolicyのみが有効になります。 @@ -265,34 +262,7 @@ properties('workload_group'='normal') ### Workload Policy デモンストレーション -#### 1. セッション変数変更テスト -Adminアカウントのセッション変数で同時実行関連パラメータの変更を試行します。 - -```sql --- log on admin to check variables -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a Policy to modify the concurrency parameters of the admin account. -create workload Policy test_set_var_Policy -Conditions(username='admin') -Actions(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- After some time, check the admin account's parameters again. -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` -#### 2. Big Query Circuit Breaker Test +#### Big Query Circuit Breaker Test 3秒を超えて実行されるクエリをサーキットブレークするテスト。以下は、ckbenchのq29の正常実行の監査ログで、このSQLが完了するまでに4.5秒かかったことを示している。 ```sql diff --git a/ja-source/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/ja-source/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index 856c71ecedda9..1debeda897fb8 100644 --- a/ja-source/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/ja-source/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -1,47 +1,72 @@ --- { - "title": "CREATE WORKLOAD GROUP | コンピュート管理", - "language": "ja", - "description": "この文は workload group を作成するために使用されます。Workload group により、単一の be 上で cpu リソースと memory リソースの分離が可能になります。", - "sidebar_label": "CREATE WORKLOAD GROUP" + "title": "CREATE WORKLOAD POLICY", + "language": "ja", + "description": "Workload Policyを作成します。クエリが特定の条件を満たした場合に、対応するアクションを実行するために使用します。" } --- -# CREATE WORKLOAD GROUP ## 説明 -このステートメントはworkload groupを作成するために使用されます。Workload groupは単一のbe上でcpuリソースとメモリリソースの分離を可能にします。 +Workload Policyを作成します。クエリが特定の条件を満たした場合に、対応するアクションを実行するために使用します。 -文法: +## 構文 ```sql -CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" -PROPERTIES ( - property_list -); +CREATE WORKLOAD POLICY [ IF NOT EXISTS ] +CONDITIONS() ACTIONS() +[ PROPERTIES () ] ``` -説明: -property_listでサポートされるプロパティ: +## 必須パラメータ -* cpu_share: 必須、ワークロードグループが取得できるcpu時間の量を設定するために使用され、cpuリソースのソフト分離を実現できます。cpu_shareは、実行中のワークロードグループが利用可能なcpuリソースの重みを示す相対値です。例えば、ユーザーがcpu_shareをそれぞれ10、30、40に設定したワークロードグループrg-a、rg-b、rg-cの3つを作成し、ある瞬間にrg-aとrg-bがタスクを実行していてrg-cにはタスクがない場合、rg-aは (10 / (10 + 30)) = 25%のcpuリソースを取得でき、ワークロードグループrg-bは75%のcpuリソースを取得できます。システムで実行中のワークロードグループが1つだけの場合、そのcpu_shareの値に関係なく、すべてのcpuリソースを取得します。 +1. ``:Workload Policyの名前です。 -* memory_limit: 必須、ワークロードグループが使用できるbeメモリの割合を設定します。ワークロードグループのメモリ制限の絶対値は: `physical_memory * mem_limit * memory_limit`で、mem_limitはbe設定項目です。システム内のすべてのワークロードグループのmemory_limitの合計は100%を超えてはいけません。ワークロードグループは、ほとんどの場合、グループ内のタスクに対してmemory_limitの使用が保証されます。ワークロードグループのメモリ使用量がこの制限を超えた場合、excess memoryを解放するために、グループ内でメモリ使用量がより大きいタスクがキャンセルされる可能性があります。enable_memory_overcommitを参照してください。 +2. `` + - be_scan_rows:1つのBEプロセス内でSQLがスキャンした行数です。SQLがBE上で複数の並行処理によって実行される場合は、各並行処理の累積値です。 + - be_scan_bytes:1つのBEプロセス内でSQLがスキャンしたバイト数です。SQLがBE上で複数の並行処理によって実行される場合は、各並行処理の累積値です。単位はバイトです。 + - query_time:単一のBEプロセス上でのSQLの実行時間です。単位はミリ秒です。 + - query_be_memory_bytes:バージョン2.1.5以降でサポートされています。1つのBEプロセス内でSQLが使用するメモリ量です。SQLがBE上で複数の並行処理によって実行される場合は、各並行処理の累積値です。単位はバイトです。 -* enable_memory_overcommit: オプション、ワークロードグループのソフトメモリ分離を有効にします。デフォルトはfalseです。falseに設定されている場合、ワークロードグループはハードメモリ分離され、ワークロードグループのメモリ使用量が制限を超えた直後に、メモリ使用量が最大のタスクが直ちにキャンセルされ、excess memoryが解放されます。trueに設定されている場合、ワークロードグループはハードメモリ分離され、ワークロードグループのメモリ使用量が制限を超えた直後に、メモリ使用量が最大のタスクが直ちにキャンセルされ、excess memoryが解放されます。trueに設定されている場合、ワークロードグループはソフト分離され、システムに空きメモリリソースがある場合、ワークロードグループはmemory_limit制限を超えた後もシステムメモリを継続して使用でき、システムの総メモリが不足している場合は、メモリ占有量が最大のグループ内の複数のタスクをキャンセルし、システムメモリ圧迫を緩和するためにexcess memoryの一部を解放します。ワークロードグループでこの設定を有効にする場合、すべてのワークロードグループのmemory_limitの合計は100%未満にし、残りの部分をワークロードグループのメモリovercommitに使用することが推奨されます。 +3. `` + - cancel_query:クエリをキャンセルします。 + +## オプションパラメータ + +1. `` + - enabled:trueまたはfalseを指定できます。デフォルトはtrueです。trueの場合はポリシーが有効になり、falseの場合は無効になります。 + - priority:0から100までの整数を指定できます。デフォルトは0です。値が大きいほど優先度が高くなります。複数のポリシーがクエリに一致した場合は、優先度が最も高いポリシーが選択されます。 + - workload_group:ポリシーを1つのWorkload Groupにバインドできます。バインドした場合、そのポリシーは該当するWorkload Groupに対してのみ有効になります。デフォルトは空で、すべてのクエリに適用されます。 + + Workload Group自体がCompute Groupに属するため、このプロパティの値は次の規則に従う必要があります。 + + - **クラウド(ストレージ・コンピュート分離)モード**:完全修飾形式 `.` が必要です。例:`'workload_group'='compute_group_a.wg1'`。`` 単独の形式、`.` が2つ以上含まれる形式、または空のセグメント(`.wg1` や `wg1.` など)を含む形式は使用できず、次のエラーが返されます:`workload_group must be '.' in cloud mode`。 + - **非クラウド(ストレージ・コンピュート統合)モード**:次の2つの形式を使用できます。 + - ``:デフォルトのリソースグループ(`default`)配下にある同名のWorkload Groupにバインドされます。 + - `.`:リソースグループを明示的に指定します。ここでのプレフィックスは実際にはリソースグループ(Tag)を指します。構文は、一貫性を保つためにクラウドモードと共通化されています。 + + `.` が2つ以上含まれる形式、または空のセグメントを含む形式も使用できず、次のエラーが返されます:`workload_group must be '' or '.' in non-cloud mode`。 + +## アクセス制御要件 + +少なくともADMIN_PRIV権限が必要です。 ## 例 -1. g1という名前のワークロードグループを作成する: +1. 実行時間が3秒を超えたクエリをキャンセルするWorkload Policyを作成します。 + + ```sql + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) + ``` + +2. デフォルトで無効になっているWorkload Policyを作成します。 + + ```sql + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') + ``` - ```sql - create workload group if not exists g1 - properties ( - "cpu_share"="10", - "memory_limit"="30%", - "enable_memory_overcommit"="true" - ); - ``` -## キーワード +3. クラウドモードで、Compute Group `compute_group_a` 配下のWorkload Group `wg1` に対してのみ有効になるポリシーを作成します(完全修飾形式を使用します)。 -CREATE、WORKLOAD、GROUP + ```sql + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('workload_group'='compute_group_a.wg1') + ``` diff --git a/ja-source/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md b/ja-source/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md index d7539108cf581..43c97dd13112b 100644 --- a/ja-source/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md +++ b/ja-source/docusaurus-plugin-content-docs/version-2.1/admin-manual/workload-management/sql-blocking.md @@ -225,18 +225,16 @@ Workload Policyを作成する際は、以下を指定する必要がありま | Conditions | 説明 | |-----------------------|-----------------------------------------------------------------------------------------------------| -| username | クエリが保持するユーザー名、FEの`set_session_variable` Actionのみをトリガーします。 | | be_scan_rows | 単一のBEプロセスでSQLがスキャンした行数。SQLがBE上で並行実行される場合、複数の並行実行の累積値となります。 | | be_scan_bytes | 単一のBEプロセスでSQLがスキャンしたバイト数。SQLがBE上で並行実行される場合、複数の並行実行の累積値となり、単位はバイトです。 | | query_time | 単一のBEプロセスでのSQLの実行時間、単位はミリ秒です。 | | query_be_memory_bytes | 単一のBEプロセスでのSQLのメモリ使用量。SQLがBE上で並行実行される場合、複数の並行実行の累積値となり、単位はバイトです。 | -- **Action**は条件がトリガーされた際に実行されるアクションを表します。現在、Policyは1つのActionのみを定義できます(`set_session_variable`を除く)。上記の例では、`cancel_query`はクエリのキャンセルを示しています。現在サポートされているActionは以下の通りです: +- **Action**は条件がトリガーされた際に実行されるアクションを表します。現在、Policyは1つのActionのみを定義できます。上記の例では、`cancel_query`はクエリのキャンセルを示しています。現在サポートされているActionは以下の通りです: | Actions | 説明 | |------------------------|------------------------------------------------------------------------------------------------------------------| | cancel_query | クエリをキャンセルします。 | -| set_session_variable | `set session variable`文をトリガーします。単一のpolicyは複数の`set_session_variable`オプションを持つことができ、現在は`username` ConditionによってFEでのみトリガーされます。 | - **Properties**は現在のPolicyの属性を定義し、有効かどうかとその優先度を含みます。 @@ -257,7 +255,6 @@ Actions(cancel_query) properties('workload_group'='normal') ``` ### 重要な注意事項 -- 同一のPolicyのConditionsとActionsは、両方ともFEであるか両方ともBEである必要があります。例えば、`set_session_variable`と`cancel_query`を同一のPolicy内で設定することはできません。Conditions `be_scan_rows`と`username`を同一のPolicy内で設定することはできません。 - 現在、Policyは固定時間間隔で非同期スレッドによって実行されるため、ポリシー実行に一定の遅延が生じます。例えば、ユーザーがスキャン行数が1,000,000を超えた場合にクエリをキャンセルするポリシーを設定し、その時点でクラスタリソースが比較的アイドル状態である場合、キャンセルポリシーが効果を発揮する前にクエリが完了する可能性があります。現在の間隔は500msであり、この間隔より短い実行時間のクエリはポリシーチェックを回避する可能性があります。 - 現在サポートされているロードタイプには、select/insert、select/stream load、broker load、routine loadが含まれます。 - 単一のクエリは複数のPolicyにマッチする可能性がありますが、最も高い優先度を持つPolicyのみが有効になります。 @@ -265,34 +262,7 @@ properties('workload_group'='normal') ### Workload Policy実証 -#### 1. Session Variable変更テスト -Adminアカウントのセッション変数で同時実行関連パラメータの変更を試行します。 - -```sql --- log on admin to check variables -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a Policy to modify the concurrency parameters of the admin account. -create workload Policy test_set_var_Policy -Conditions(username='admin') -Actions(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- After some time, check the admin account's parameters again. -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` -#### 2. Big Query Circuit Breaker Test +#### Big Query Circuit Breaker Test 3秒より長く実行されるクエリを回路遮断するテスト。以下は、ckbenchのq29の正常実行の監査ログで、このSQLが完了するのに4.5秒かかったことを示している。 ```sql diff --git a/ja-source/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/ja-source/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index 399471a94bb94..eb873cff76386 100644 --- a/ja-source/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/ja-source/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -33,8 +33,7 @@ Workload Policyの名前。 `` -1. **set_session_variable**: このアクションはset session variable文を実行します。同一ポリシー内で複数の**set_session_variable**アクションを指定でき、1つのポリシー内で複数のセッション変数変更文を実行することができます。 -2. **cancel_query**: クエリをキャンセルします。 +1. **cancel_query**: クエリをキャンセルします。 ### オプションパラメータ diff --git a/ja-source/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md b/ja-source/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md index 6171b7c8f8ae7..8eeeed092d58c 100644 --- a/ja-source/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md +++ b/ja-source/docusaurus-plugin-content-docs/version-3.x/admin-manual/workload-management/sql-blocking.md @@ -225,18 +225,16 @@ Workload Policyを作成する際は、以下を指定する必要がありま | Conditions | Description | |-----------------------|-------------------------------------------------------------------------------------------------------------| -| username | クエリによって伝達されるユーザー名。FEにおいて`set_session_variable` Actionのみをトリガーします。 | | be_scan_rows | 単一のBEプロセスでSQLによってスキャンされた行数。SQLがBE上で並行実行される場合、複数の並行実行の累積値になります。 | | be_scan_bytes | 単一のBEプロセスでSQLによってスキャンされたバイト数。SQLがBE上で並行実行される場合、複数の並行実行の累積値になります(単位:バイト)。 | | query_time | 単一のBEプロセスにおけるSQLの実行時間(単位:ミリ秒)。 | | query_be_memory_bytes | 単一のBEプロセスにおけるSQLのメモリ使用量。SQLがBE上で並行実行される場合、複数の並行実行の累積値になります(単位:バイト)。 | -- **Action**は条件がトリガーされた際に実行されるアクションを表します。現在、Policyは1つのActionのみ定義できます(`set_session_variable`を除く)。上記の例では、`cancel_query`はクエリのキャンセルを示しています。現在サポートされているActionは以下の通りです: +- **Action**は条件がトリガーされた際に実行されるアクションを表します。現在、Policyは1つのActionのみ定義できます。上記の例では、`cancel_query`はクエリのキャンセルを示しています。現在サポートされているActionは以下の通りです: | Actions | Description | |------------------------|------------------------------------------------------------------------------------------------------------------| | cancel_query | クエリをキャンセルします。 | -| set_session_variable | `set session variable`文をトリガーします。単一のpolicyは複数の`set_session_variable`オプションを持つことができ、現在は`username` ConditionによってFEでのみトリガーされます。 | - **Properties**は現在のPolicyの属性を定義し、有効かどうかとその優先度が含まれます。 @@ -257,7 +255,6 @@ Actions(cancel_query) properties('workload_group'='normal') ``` ### 重要な注意事項 -- 同じPolicyのConditionsとActionsは、両方ともFEであるか両方ともBEである必要があります。例えば、`set_session_variable`と`cancel_query`は同じPolicy内で設定することはできません。Conditions `be_scan_rows`と`username`は同じPolicy内で設定することはできません。 - 現在、Policyは固定時間間隔で非同期スレッドによって実行されるため、ポリシー実行に一定の遅延が生じます。例えば、ユーザーがスキャン行数が1,000,000を超えた場合にクエリをキャンセルするポリシーを設定し、その時点でクラスターリソースが比較的アイドル状態の場合、キャンセルポリシーが有効になる前にクエリが完了する可能性があります。現在の間隔は500msであり、この間隔より短い実行時間のクエリはポリシーチェックを回避する可能性があります。 - 現在サポートされているロードタイプには、select/insert、select/stream load、broker load、routine loadが含まれます。 - 単一のクエリは複数のPolicyにマッチする可能性がありますが、最も高い優先度を持つPolicyのみが有効になります。 @@ -265,34 +262,7 @@ properties('workload_group'='normal') ### Workload Policyデモンストレーション -#### 1. Session Variable修正テスト -Adminアカウントのセッション変数で並行処理関連のパラメータの修正を試行します。 - -```sql --- log on admin to check variables -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a Policy to modify the concurrency parameters of the admin account. -create workload Policy test_set_var_Policy -Conditions(username='admin') -Actions(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- After some time, check the admin account's parameters again. -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` -#### 2. Big Query Circuit Breaker Test +#### Big Query Circuit Breaker Test 3秒を超えて実行されるクエリをサーキットブレイクするテスト。以下は、ckbenchのq29の成功実行の監査ログで、このSQLの完了に4.5秒かかったことを示しています。 ```sql diff --git a/ja-source/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/ja-source/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index c64bbd102de83..65bc99ff3c091 100644 --- a/ja-source/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/ja-source/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -1,47 +1,61 @@ --- { - "title": "CREATE WORKLOAD GROUP | コンピュート管理", - "sidebar_label": "CREATE WORKLOAD GROUP", - "description": "このステートメントはワークロードグループを作成するために使用されます。ワークロードグループは、単一のbe上でcpuリソースとメモリリソースの分離を可能にします。", - "language": "ja" + "title": "CREATE WORKLOAD POLICY を作成", + "language": "ja", + "description": "特定の条件を満たすクエリに対して対応するアクションを実行するためのWorkload Policyを作成します。" } --- -# CREATE WORKLOAD GROUP +## 説明 -## デスクリプション +特定の条件を満たすクエリに対して対応するアクションを実行するWorkload Policyを作成します。 -このステートメントはワークロードグループを作成するために使用されます。ワークロードグループは、単一のbe上でcpuリソースとmemoryリソースの分離を可能にします。 -grammar: +## 構文 ```sql -CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" -PROPERTIES ( - property_list -); +CREATE WORKLOAD POLICY [ IF NOT EXISTS ] +CONDITIONS() ACTIONS() +[ PROPERTIES () ] ``` -図解: +### 必須パラメータ -property_listでサポートされるプロパティ: +`` -* cpu_share: 必須、ワークロードグループが取得できるCPU時間の設定に使用され、CPUリソースのソフト分離を実現できます。cpu_shareは実行中のワークロードグループで利用可能なCPUリソースの重みを示す相対値です。例えば、ユーザーがcpu_shareをそれぞれ10、30、40に設定した3つのワークロードグループrg-a、rg-b、rg-cを作成し、ある時点でrg-aとrg-bがタスクを実行している一方、rg-cにタスクがない場合、rg-aは(10 / (10 + 30)) = 25%のCPUリソースを取得でき、ワークロードグループrg-bは75%のCPUリソースを取得できます。システムで実行されているワークロードグループが1つだけの場合、そのcpu_shareの値に関係なく、すべてのCPUリソースを取得します。 +Workload Policyの名前。 -* memory_limit: 必須、ワークロードグループが使用できるbeメモリの割合を設定します。ワークロードグループのメモリ制限の絶対値は: `physical_memory * mem_limit * memory_limit`です。ここでmem_limitはbeの設定項目です。システム内のすべてのワークロードグループのmemory_limitの合計は100%を超えてはいけません。ワークロードグループは、ほとんどの場合、グループ内のタスクに対してmemory_limitの使用が保証されます。ワークロードグループのメモリ使用量がこの制限を超えた場合、グループ内でより多くのメモリを使用しているタスクがキャンセルされ、超過分のメモリが解放される場合があります。enable_memory_overcommitを参照してください。 -* enable_memory_overcommit: オプション、ワークロードグループのソフトメモリ分離を有効にします。デフォルトはfalseです。falseに設定した場合、ワークロードグループはハードメモリ分離され、ワークロードグループのメモリ使用量が制限を超えた直後に最大のメモリ使用量を持つタスクが即座にキャンセルされ、超過分のメモリが解放されます。trueに設定した場合、ワークロードグループはハードメモリ分離され、ワークロードグループのメモリ使用量が制限を超えた直後に最大のメモリ使用量を持つタスクが即座にキャンセルされ、超過分のメモリが解放されます。trueに設定した場合、ワークロードグループはソフト分離され、システムに空きメモリリソースがある場合、ワークロードグループはmemory_limit制限を超えてシステムメモリを継続して使用でき、システム全体のメモリが逼迫した時に、グループ内で最大のメモリ使用量を持ついくつかのタスクをキャンセルし、超過分のメモリの一部を解放してシステムメモリ圧迫を緩和します。ワークロードグループでこの設定を有効にする場合、すべてのワークロードグループのmemory_limitの合計を100%未満にし、残りの部分をワークロードグループのメモリオーバーコミット用に使用することを推奨します。 + +1. **be_scan_rows**: 単一のBEプロセス内でSQLクエリによってスキャンされた行数。SQLクエリが複数のBE上で並行して実行される場合、これらの並行実行の累積値となります。 +2. **be_scan_bytes**: 単一のBEプロセス内でSQLクエリによってスキャンされたバイト数。SQLクエリが複数のBE上で並行して実行される場合、これらの並行実行の累積値となります(バイト単位)。 +3. **query_time**: 単一のBEプロセス上でのSQLクエリの実行時間(ミリ秒単位)。 +4. **query_be_memory_bytes**(バージョン2.1.5からサポート): 単一のBEプロセス内でSQLクエリによって使用されるメモリ量。SQLクエリが複数のBE上で並行して実行される場合、これらの並行実行の累積値となります(バイト単位)。 + + +`` + +1. **cancel_query**: クエリをキャンセルします。 + +### オプションパラメータ + + + +1. **enabled**: trueまたはfalseの値を取り、デフォルト値はtrueです。trueに設定するとポリシーが有効になり、falseに設定するとポリシーが無効になります。 +2. **priority**: 0から100の範囲の整数値で、デフォルト値は0です。これはポリシーの優先度を表します。値が高いほど優先度が高くなります。複数のポリシーがマッチした場合、最も優先度の高いポリシーが選択されます。 +3. **workload_group**: 現在、ポリシーは1つのworkload groupにバインドでき、このポリシーが特定のworkload groupにのみ適用されることを示します。デフォルトは空で、すべてのクエリに適用されることを意味します。 + +### アクセス制御要件 + +最低でも`ADMIN_PRIV`権限が必要です。 ## 例 -1. g1という名前のワークロードグループを作成: +1. クエリ時間が3秒を超えるすべてのクエリをkillする新しいWorkload Policyを作成します。 - ```sql - create workload group if not exists g1 - properties ( - "cpu_share"="10", - "memory_limit"="30%", - "enable_memory_overcommit"="true" - ); - ``` -## Keywords + ```Java + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) + ``` +1. デフォルトで有効にならない新しいWorkload Policyを作成します。 -CREATE、WORKLOAD、GROUP + ```Java + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') + ``` diff --git a/ja-source/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md b/ja-source/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md index cfe74535eed55..5e9068c569da9 100644 --- a/ja-source/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md +++ b/ja-source/docusaurus-plugin-content-docs/version-4.x/admin-manual/workload-management/sql-blocking.md @@ -225,18 +225,16 @@ Workload Policyを作成する際は、以下を指定する必要がありま | Conditions | Description | |-----------------------|-------------------------------------------------------------------------------------------------------------| -| username | クエリが持つユーザー名。FEでの`set_session_variable` Actionのみをトリガーします。 | | be_scan_rows | 単一のBEプロセスでSQLによってスキャンされた行数。SQLがBE上で並行実行される場合は、複数の並行実行の累積値です。 | | be_scan_bytes | 単一のBEプロセスでSQLによってスキャンされたバイト数。SQLがBE上で並行実行される場合は、複数の並行実行の累積値で、単位はバイトです。 | | query_time | 単一のBEプロセスでのSQLの実行時間、単位はミリ秒です。 | | query_be_memory_bytes | 単一のBEプロセスでのSQLのメモリ使用量。SQLがBE上で並行実行される場合は、複数の並行実行の累積値で、単位はバイトです。 | -- **Action**は条件がトリガーされた際に実行されるアクションを表します。現在、Policyは1つのActionのみを定義できます(`set_session_variable`を除く)。上記の例では、`cancel_query`はクエリをキャンセルすることを示しています。現在サポートされているActionは以下の通りです: +- **Action**は条件がトリガーされた際に実行されるアクションを表します。現在、Policyは1つのActionのみを定義できます。上記の例では、`cancel_query`はクエリをキャンセルすることを示しています。現在サポートされているActionは以下の通りです: | Actions | Description | |------------------------|------------------------------------------------------------------------------------------------------------------| | cancel_query | クエリをキャンセルします。 | -| set_session_variable | `set session variable`文をトリガーします。単一のポリシーは複数の`set_session_variable`オプションを持つことができ、現在は`username` ConditionによってFEでのみトリガーされます。 | - **Properties**は現在のPolicyの属性を定義し、有効かどうかと優先度を含みます。 @@ -257,7 +255,6 @@ Actions(cancel_query) properties('workload_group'='normal') ``` ### 重要な注意事項 -- 同一のPolicyのConditionsとActionsは、両方ともFEまたは両方ともBEのいずれかである必要があります。例えば、`set_session_variable`と`cancel_query`を同一のPolicy内で設定することはできません。Conditions `be_scan_rows`と`username`を同一のPolicy内で設定することはできません。 - 現在、Policyは固定時間間隔で非同期スレッドによって実行されるため、ポリシー実行に一定の遅延が生じます。例えば、ユーザーがスキャンされた行数が1,000,000を超えた際にクエリをキャンセルするポリシーを設定し、その時点でクラスタリソースが比較的アイドル状態である場合、キャンセルポリシーが有効になる前にクエリが完了する可能性があります。現在の間隔は500msであり、この間隔より短い実行時間のクエリはポリシーチェックを回避する可能性があります。 - 現在サポートされているロードタイプには、select/insert、select/stream load、broker load、routine loadが含まれます。 - 単一のクエリは複数のPolicyにマッチする可能性がありますが、最も優先度の高いPolicyのみが有効になります。 @@ -265,34 +262,7 @@ properties('workload_group'='normal') ### Workload Policyデモンストレーション -#### 1. Session Variable変更テスト -AdminアカウントのセッションVariable内の並行性関連パラメータの変更を試行します。 - -```sql --- log on admin to check variables -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 8 | 8 | 0 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.00 sec) - --- Create a Policy to modify the concurrency parameters of the admin account. -create workload Policy test_set_var_Policy -Conditions(username='admin') -Actions(set_session_variable 'parallel_fragment_exec_instance_num=1') - --- After some time, check the admin account's parameters again. -show variables like '%parallel_fragment_exec_instance_num%'; -+-------------------------------------+-------+---------------+---------+ -| Variable_name | Value | Default_Value | Changed | -+-------------------------------------+-------+---------------+---------+ -| parallel_fragment_exec_instance_num | 1 | 8 | 1 | -+-------------------------------------+-------+---------------+---------+ -1 row in set (0.01 sec) -``` -#### 2. Big Query Circuit Breaker Test +#### Big Query Circuit Breaker Test 3秒以上実行されるクエリを回路遮断するテスト。以下は、ckbenchのq29の正常実行の監査ログで、このSQLの完了に4.5秒かかったことを示している。 ```sql diff --git a/ja-source/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/ja-source/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md index 8aaffbac707e2..1debeda897fb8 100644 --- a/ja-source/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md +++ b/ja-source/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -1,47 +1,72 @@ --- { - "title": "CREATE WORKLOAD GROUP | コンピュート管理", - "sidebar_label": "CREATE WORKLOAD GROUP", - "description": "このステートメントはワークロードグループを作成するために使用されます。ワークロードグループは、単一のbe上でcpuリソースとメモリリソースの分離を可能にします。", - "language": "ja" + "title": "CREATE WORKLOAD POLICY", + "language": "ja", + "description": "Workload Policyを作成します。クエリが特定の条件を満たした場合に、対応するアクションを実行するために使用します。" } --- -# CREATE WORKLOAD GROUP ## 説明 -このステートメントはworkload groupを作成するために使用されます。Workload groupは単一のbe上でcpuリソースとmemoryリソースの分離を可能にします。 +Workload Policyを作成します。クエリが特定の条件を満たした場合に、対応するアクションを実行するために使用します。 -文法: +## 構文 ```sql -CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" -PROPERTIES ( - property_list -); +CREATE WORKLOAD POLICY [ IF NOT EXISTS ] +CONDITIONS() ACTIONS() +[ PROPERTIES () ] ``` -illustrate: -property_listでサポートされているプロパティ: +## 必須パラメータ -* cpu_share: 必須。ワークロードグループが取得できるcpu時間を設定するために使用され、cpuリソースのソフト分離を実現できます。cpu_shareは実行中のワークロードグループが利用可能なcpuリソースの重みを示す相対値です。例えば、ユーザーがcpu_shareをそれぞれ10、30、40に設定した3つのワークロードグループrg-a、rg-b、rg-cを作成し、ある時点でrg-aとrg-bがタスクを実行しているがrg-cにはタスクがない場合、rg-aは(10 / (10 + 30)) = 25%のcpuリソースを取得でき、ワークロードグループrg-bは75%のcpuリソースを取得できます。システムで実行されているワークロードグループが1つだけの場合、そのcpu_shareの値に関係なく、すべてのcpuリソースを取得します。 +1. ``:Workload Policyの名前です。 -* memory_limit: 必須。ワークロードグループが使用できるbeメモリの割合を設定します。ワークロードグループメモリ制限の絶対値は:`physical_memory * mem_limit * memory_limit`で、mem_limitはbe設定項目です。システム内のすべてのワークロードグループの合計memory_limitは100%を超えてはいけません。ワークロードグループは、ほとんどの場合、グループ内のタスクに対してmemory_limitの使用が保証されています。ワークロードグループのメモリ使用量がこの制限を超えた場合、メモリ使用量の多いグループ内のタスクがキャンセルされ、超過メモリが解放される可能性があります。enable_memory_overcommitを参照してください。 +2. `` + - be_scan_rows:1つのBEプロセス内でSQLがスキャンした行数です。SQLがBE上で複数の並行処理によって実行される場合は、各並行処理の累積値です。 + - be_scan_bytes:1つのBEプロセス内でSQLがスキャンしたバイト数です。SQLがBE上で複数の並行処理によって実行される場合は、各並行処理の累積値です。単位はバイトです。 + - query_time:単一のBEプロセス上でのSQLの実行時間です。単位はミリ秒です。 + - query_be_memory_bytes:バージョン2.1.5以降でサポートされています。1つのBEプロセス内でSQLが使用するメモリ量です。SQLがBE上で複数の並行処理によって実行される場合は、各並行処理の累積値です。単位はバイトです。 -* enable_memory_overcommit: オプション。ワークロードグループのソフトメモリ分離を有効にします。デフォルトはfalseです。falseに設定された場合、ワークロードグループはハードメモリ分離され、ワークロードグループのメモリ使用量が制限を超えた直後に、メモリ使用量が最も大きいタスクが即座にキャンセルされ、超過メモリが解放されます。trueに設定された場合、ワークロードグループはハードメモリ分離され、ワークロードグループのメモリ使用量が制限を超えた直後に、メモリ使用量が最も大きいタスクが即座にキャンセルされ、超過メモリが解放されます。trueに設定された場合、ワークロードグループはソフト分離され、システムに空きメモリリソースがある場合、ワークロードグループはmemory_limit制限を超えてもシステムメモリを継続して使用でき、システム全体のメモリが逼迫した場合、グループ内でメモリ占有量が最も大きい複数のタスクをキャンセルし、超過メモリの一部を解放してシステムメモリ圧迫を緩和します。この設定をワークロードグループで有効にする場合、すべてのワークロードグループの合計memory_limitを100%未満にし、残りの部分をワークロードグループメモリオーバーコミット用に使用することを推奨します。 +3. `` + - cancel_query:クエリをキャンセルします。 -## Example +## オプションパラメータ -1. g1という名前のワークロードグループを作成する: +1. `` + - enabled:trueまたはfalseを指定できます。デフォルトはtrueです。trueの場合はポリシーが有効になり、falseの場合は無効になります。 + - priority:0から100までの整数を指定できます。デフォルトは0です。値が大きいほど優先度が高くなります。複数のポリシーがクエリに一致した場合は、優先度が最も高いポリシーが選択されます。 + - workload_group:ポリシーを1つのWorkload Groupにバインドできます。バインドした場合、そのポリシーは該当するWorkload Groupに対してのみ有効になります。デフォルトは空で、すべてのクエリに適用されます。 - ```sql - create workload group if not exists g1 - properties ( - "cpu_share"="10", - "memory_limit"="30%", - "enable_memory_overcommit"="true" - ); - ``` -## Keywords + Workload Group自体がCompute Groupに属するため、このプロパティの値は次の規則に従う必要があります。 -CREATE、WORKLOAD、GROUP + - **クラウド(ストレージ・コンピュート分離)モード**:完全修飾形式 `.` が必要です。例:`'workload_group'='compute_group_a.wg1'`。`` 単独の形式、`.` が2つ以上含まれる形式、または空のセグメント(`.wg1` や `wg1.` など)を含む形式は使用できず、次のエラーが返されます:`workload_group must be '.' in cloud mode`。 + - **非クラウド(ストレージ・コンピュート統合)モード**:次の2つの形式を使用できます。 + - ``:デフォルトのリソースグループ(`default`)配下にある同名のWorkload Groupにバインドされます。 + - `.`:リソースグループを明示的に指定します。ここでのプレフィックスは実際にはリソースグループ(Tag)を指します。構文は、一貫性を保つためにクラウドモードと共通化されています。 + + `.` が2つ以上含まれる形式、または空のセグメントを含む形式も使用できず、次のエラーが返されます:`workload_group must be '' or '.' in non-cloud mode`。 + +## アクセス制御要件 + +少なくともADMIN_PRIV権限が必要です。 + +## 例 + +1. 実行時間が3秒を超えたクエリをキャンセルするWorkload Policyを作成します。 + + ```sql + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) + ``` + +2. デフォルトで無効になっているWorkload Policyを作成します。 + + ```sql + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') + ``` + +3. クラウドモードで、Compute Group `compute_group_a` 配下のWorkload Group `wg1` に対してのみ有効になるポリシーを作成します(完全修飾形式を使用します)。 + + ```sql + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('workload_group'='compute_group_a.wg1') + ```