starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[Feature] Support kill query by custom_query_id

Open kaijianding opened this issue 1 year ago • 5 comments

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 avatar Jun 28 '24 07:06 kaijianding

@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.

imay avatar Jun 29 '24 06:06 imay

@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.

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.

kaijianding avatar Jul 01 '24 10:07 kaijianding

@alvin-celerdata this pr is modified to only kill query by query id, please review.

kaijianding avatar Jul 04 '24 15:07 kaijianding

@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?

alvin-celerdata avatar Jul 04 '24 18:07 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

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

kaijianding avatar Jul 05 '24 03:07 kaijianding

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 avatar Jul 05 '24 05:07 alvin-celerdata

@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

kaijianding avatar Jul 05 '24 06:07 kaijianding

[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% []

github-actions[bot] avatar Jul 09 '24 07:07 github-actions[bot]

[BE Incremental Coverage Report]

:white_check_mark: pass : 0 / 0 (0%)

github-actions[bot] avatar Jul 09 '24 08:07 github-actions[bot]

ignore backport check: 3.3.1

wangsimo0 avatar Jul 10 '24 08:07 wangsimo0

ignore backport check: 3.3.2

kangkaisen avatar Jul 24 '24 06:07 kangkaisen