Repository navigation
Add a setting to throw exception when no query to kill - #85023
Conversation
|
Workflow [PR], commit [aaec9e3] Summary: ✅
AI ReviewSummaryThis PR adds the PR Metadata
Findings
Final VerdictRequest changes. Fix the stale changelog entry and add one no-op test that uses the implicit default before merging. LLVM Coverage ReportMeasured on commit aaec9e3.
Changed lines: Changed C/C++ lines covered: 61/61 (100.00%) · Uncovered code |
c6f3e54 to
e0e85bc
Compare
3c758c1 to
3f63dfe
Compare
|
@yariks5s Hi, any suggestions in failed tests? |
|
Dear @yariks5s, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Could you please update with master once more? |
1e571d8 to
c364251
Compare
Of course, I've done. |
|
@zwy991114 can we please also add a tests with enabled setting that kills the existing query? It should not throw an error and we need to check it in tests. |
|
@zwy991114 Hi, would you consider renaming the error code from
Currently, Thanks. |
…he current `KILL` statement
|
good idea! |
Conflicts resolved: - `InterpreterKillQueryQuery.cpp`: kept master's reduced/self-kill descriptor path (`selfKillDescriptors` from ClickHouse#117999) and re-applied the empty-match throw (`NOTHING_TO_KILL`) after descriptor selection. - `SettingsChangesHistory.cpp`: kept both new 26.10 entries (master's `analyzer_compatibility_allow_cte_redefinition` and ours `kill_throw_if_noop`). Verified: full build clean; `05233_kill_throw_if_noop`, `00417_kill_query`, `01003_kill_query_race_condition` pass against the merged binary. Co-Authored-By: Claude Code <[email protected]>
The self-kill path merged from zwy/master (ClickHouse#117999) documents that a user holding neither `SELECT` on `system.processes` nor `KILL QUERY` gets "no rows rather than reporting an error" when naming an id that is not running as them. With `kill_throw_if_noop` enabled (the default), that no-op now throws instead, so say so explicitly in the statement docs. Co-Authored-By: Claude Code <[email protected]>
…row_if_noop # Conflicts: # src/Core/SettingsChangesHistory.cpp
|
@yariks5s hi, please review this PR one more time. |
Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # tests/integration/test_phantom_parts_in_mutations/test.py
yariks5s
left a comment
There was a problem hiding this comment.
Change is really simple, the finding is not severe, the only change we need to think about is about enabling it by default, we need a good reason for that
| - 1 - Enable | ||
| )", 0, \ | ||
| {"25.12", false, true, "New setting. Add optimization to remove unused columns in query plan."}) \ | ||
| DECLARE(Bool, kill_throw_if_noop, true, R"( |
There was a problem hiding this comment.
also a question: do we really want it to be enabled by default? This is a backward-incompatible change, then. That is not bad, but we need a good reason for this incompatible change and for it to be noted (change the changelog category). For me, having it set to false by default is just fine.
There was a problem hiding this comment.
@yariks5s I feel the same. Potentially it can break existing "kill" automations because they will get exception in some cases. Personally I would like to keep it disabled by default and let users to adopt code 1st.
There was a problem hiding this comment.
@zwy991114 its better to keep default=false for this parameter. It will be change to 'true' next release/pr.
What do you think?
There was a problem hiding this comment.
@alexey-sitnikov-ch I agree with this approach as well; in fact, I also wanted to set the default value to false from the start.
|
I just saw the initial issue by Nikita mentioning that it can be enabled by default. Ok, but we need to change the changelog category to the backwards incompatible change in this case |
|
Also, the relevant test has failed in CI, due to timeout. It would be nice to speed up the test so there is no chance it fails with timeout in the CI. |
Future PR or relase will change default to true Removed redundant integration test (there is stateless test already).
| # `kill_throw_if_noop` is enabled by default. `05233_kill_throw_if_noop.sql` covers the absent | ||
| # query_id / mutation_id cases; this test covers the rest of what the former integration suite | ||
| # `test_kill_throw_if_noop` exercised: `user = currentUser()` matching nothing (sections 1-2), | ||
| # killing a running query without throwing (section 4), `KILL MUTATION` with an empty match | ||
| # (sections 5-6), and the `TEST` dry runs staying previews instead of throwing (sections 3, 7). | ||
| # A dedicated, otherwise idle user keeps the `currentUser()` outcome deterministic while | ||
| # stateless tests run in parallel. | ||
|
|
||
| ID="${CLICKHOUSE_TEST_UNIQUE_NAME}" | ||
| USER="kq_$ID" | ||
|
|
||
| $CLICKHOUSE_CLIENT -q "DROP USER IF EXISTS $USER" | ||
| $CLICKHOUSE_CLIENT -q "CREATE USER $USER IDENTIFIED WITH no_password" | ||
| $CLICKHOUSE_CLIENT -q "GRANT SELECT ON system.numbers TO $USER" | ||
| $CLICKHOUSE_CLIENT -q "GRANT SELECT(query_id, user, query) ON system.processes TO $USER" | ||
|
|
||
| echo "-- 1. user = currentUser() matches only the caller's own rows, and the KILL statement itself is excluded; with the dedicated user idle otherwise, the match is empty and the default throws" | ||
| OUT=$($CLICKHOUSE_CLIENT --user "$USER" -q "KILL QUERY WHERE user = currentUser() SETTINGS kill_throw_if_noop=1" 2>&1) |
There was a problem hiding this comment.
The new stateless coverage still does not actually pin down the default value here. The header says kill_throw_if_noop is enabled by default, section 1 says "the default throws", and section 19 of 05060_kill_query_without_processes_grant still says the same thing, but the empty-match queries themselves all force kill_throw_if_noop = 1 or 0.
That means a future flip back to true would leave these no-op cases green while the test narrative and reference output say the opposite. Can we make at least one empty-match KILL QUERY / KILL MUTATION case use the implicit default and update the echoed/reference text accordingly?
|
Still looks good to me |
5e014d3
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the kill_throw_if_noop setting, enabled by default, which makes local KILL QUERY and KILL MUTATION statements throw NO_QUERY_TO_KILL when their selection produces no eligible target. ON CLUSTER execution remains tolerant of empty matches. Set
kill_throw_if_noop = falseto preserve the previous behavior.Related #83348
Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/85023]
Version info
26.10.1.1092-master(included in26.10and later)