wangbo opened a new pull request, #43406:
URL: https://github.com/apache/doris/pull/43406
Add last n second cpu usage metric for Workload Policy.
It's used to kill some query which cpu usage exceeds some value in the last
period of time.
For example:
1 create a cpu usage policy.
```
create workload policy cpu_policy2 conditions(last_10s_cpu_usage_percent >
4) actions(cancel_query);
```
2 show this policy.
```
mysql [information_schema]>select * from workload_policy;
+-------+-------------+--------------------------------+--------------+----------+---------+---------+----------------+
| ID | NAME | CONDITION | ACTION |
PRIORITY | ENABLED | VERSION | WORKLOAD_GROUP |
+-------+-------------+--------------------------------+--------------+----------+---------+---------+----------------+
| 43033 | cpu_policy2 | last_10s_cpu_usage_percent > 4 | cancel_query |
0 | 1 | 0 | |
+-------+-------------+--------------------------------+--------------+----------+---------+---------+----------------+
1 row in set (0.01 sec)
```
3 execute a insert select query, cpu usage could increase.
```
mysql [information_schema]>select CPU_USAGE_PERCENT from
backend_active_tasks where QUERY_TYPE='LOAD';
+-------------------+
| CPU_USAGE_PERCENT |
+-------------------+
| 3.78 |
+-------------------+
1 row in set (0.01 sec)
mysql [information_schema]>select CPU_USAGE_PERCENT from
backend_active_tasks where QUERY_TYPE='LOAD';
+-------------------+
| CPU_USAGE_PERCENT |
+-------------------+
| 4.8 |
+-------------------+
1 row in set (0.02 sec)
```
4 query is killed
```
mysql [hits]>insert into hits2 select * from hits;
ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INTERNAL_ERROR]query c2bffbd4474143d5-ae9346b7343b191d cancelled by
workload policy: cpu_policy2, id:43033
```
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No colde files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
- Release note
<!-- bugfix, feat, behavior changed need a release note -->
<!-- Add one line release note for this PR. -->
None
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]