[Feature] Support kill query by custom_query_id
Why I'm doing:
User want to set a user generated query id and kill query by the user specified query id
What I'm doing:
Allow set custom query id in session and kill query by this id in all running fe(leader, follower, observer).
Usage:
set custom_query_id=xx;
select ...;
show proc '/current_queries';
kill running query 'xx';
this custom_query_id is temporary, it will be removed from session after select sql is done
Fixes #47699
What type of PR is this:
- [ ] BugFix
- [x] Feature
- [ ] Enhancement
- [ ] Refactor
- [ ] UT
- [ ] Doc
- [ ] Tool
Does this PR entail a change in behavior?
- [ ] Yes, this PR will result in a change in behavior.
- [x] No, this PR will not result in a change in behavior.
Checklist:
- [ ] I have added test cases for my bug fix or my new feature
- [x] This pr needs user documentation (for new or modified features or behaviors)
- [ ] I have added documentation for my new feature or new function
- [ ] This is a backport pr
Bugfix cherry-pick branch check:
- [x] I have checked the version labels which the pr will be auto-backported to the target branch
- [x] 3.3
- [ ] 3.2
- [ ] 3.1
- [ ] 3.0
- [ ] 2.5
@kaijianding
Do you think the name custom_query_id is more suitable?
And I suggest you can split this PR into multi PRs.
One is to add new query id.
the other is to support kill by this new id.
@kaijianding Do you think the name
custom_query_idis more suitable? And I suggest you can split this PR into multi PRs. One is to add new query id. the other is to support kill by this new id.
Done renaming to custom_query_id.
Most codes are about killing query by custom_query_id, i think these code should stay in 1 pr.
@alvin-celerdata this pr is modified to only kill query by query id, please review.
@kaijianding
I want to discuss a little more on the return of this statement. What will be returned when there is a query killed? What will be returned when there is no query killed? What will be returned when some frontends are failed to connect?
What will be returned when there is a query killed?
ERROR 1064 (HY000) at line 2: killed by kill statement : OriginStatement{originStmt='kill query 'aaa'', idx=0}for the query.Query OK, 0 rows affected (0.01 sec)for the kill
What will be returned when there is no query killed?
ERROR 1365 (HY000): Unknown query id: aaa
What will be returned when some frontends are failed to connect?
ERROR 1365 (HY000): Failed to connect to fe 127.0.0.1:9020
What will be returned when there is a query killed?
ERROR 1064 (HY000) at line 2: killed by kill statement : OriginStatement{originStmt='kill query 'aaa'', idx=0}
IMO we need to return OK instead of ERROR, because this is the expected way that it works.
@alvin-celerdata
What will be returned when there is a query killed?
ERROR 1064 (HY000) at line 2: killed by kill statement : OriginStatement{originStmt='kill query 'aaa'', idx=0} for the query.
Query OK, 0 rows affected (0.01 sec) for the kill
Quality Gate passed
Issues
14 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
[FE Incremental Coverage Report]
:white_check_mark: pass : 52 / 54 (96.30%)
file detail
| path | covered_line | new_line | coverage | not_covered_line_detail | |
|---|---|---|---|---|---|
| :large_blue_circle: | com/starrocks/qe/StmtExecutor.java | 33 | 35 | 94.29% | [999, 1061] |
| :large_blue_circle: | com/starrocks/qe/LeaderOpExecutor.java | 6 | 6 | 100.00% | [] |
| :large_blue_circle: | com/starrocks/qe/ConnectScheduler.java | 6 | 6 | 100.00% | [] |
| :large_blue_circle: | com/starrocks/common/ErrorCode.java | 1 | 1 | 100.00% | [] |
| :large_blue_circle: | com/starrocks/qe/ConnectProcessor.java | 1 | 1 | 100.00% | [] |
| :large_blue_circle: | com/starrocks/sql/ast/KillStmt.java | 5 | 5 | 100.00% | [] |
[BE Incremental Coverage Report]
:white_check_mark: pass : 0 / 0 (0%)
ignore backport check: 3.3.1
ignore backport check: 3.3.2