Skip to content

Rename SYSTEM INSTRUMENT 'parameters' to 'arguments' - #103854

Merged
pamarcos merged 12 commits into
ClickHouse:masterfrom
pamarcos:xray-rename-parameters-to-arguments
May 27, 2026
Merged

pamarcos merged 12 commits into
ClickHouse:masterfrom
pamarcos:xray-rename-parameters-to-arguments

Conversation

@pamarcos

@pamarcos pamarcos commented May 1, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The XRay-based SYSTEM INSTRUMENT feature now uses arguments instead of parameters: the system.instrumentation.parameters column was renamed to arguments, and the SYSTEM INSTRUMENT ADD ... HANDLER PARAMETERS ... syntax was renamed to SYSTEM INSTRUMENT ADD ... HANDLER ARGUMENTS .... Queries or automation that use the old column or syntax must be updated to use the new names; the old names are no longer supported.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Details

In the SYSTEM INSTRUMENT feature added in #89173, the values passed to handlers (LOG, SLEEP, PROFILE) were called parameters in the system.instrumentation column, in the SQL syntax description, in internal type aliases, member names and error messages. Since they are values rather than declared placeholders, they should be called arguments.

This PR renames consistently across:

  • system.instrumentation.parameters column -> arguments (and its description)
  • The SQL syntax block in the SYSTEM INSTRUMENT ADD documentation: HANDLER [PARAMETERS] -> HANDLER [ARGUMENTS]
  • Internal C++ type aliases InstrumentedParameter -> InstrumentedArgument and InstrumentParameter -> InstrumentArgument
  • AST/parser members instrumentation_parameters -> instrumentation_arguments
  • Local variables (params/param -> args/arg) and error messages
  • The example output in system.instrumentation.md and the tests that select the column

Also rewords "the ALL parameter" to "the ALL keyword" in the SYSTEM INSTRUMENT REMOVE docs, since ALL is a SQL keyword.

Note: the system.trace_log table did not have a parameters column, so only system.instrumentation is affected.

Tests

All SYSTEM INSTRUMENT related stateless tests were run with --test-runs 3 (and --long-test-runs-ratio 1 for the stress test), all passing:

  • 03642_system_instrument_add_remove
  • 03642_system_instrument_log
  • 03642_system_instrument_sleep
  • 03642_system_instrument_profile
  • 03642_system_instrument_entry_exit
  • 03642_system_instrument_stress
  • 03642_system_instrument_symbols
  • 03642_system_instrument_multiple_handlers
  • 03642_system_instrument_dispatch_bug
  • 03643_system_instrumentation_no_suspicious_lowcardinality
  • 01271_show_privileges

Version info

  • Merged into: 26.6.1.186

pamarcos added 2 commits May 1, 2026 05:48
In the SYSTEM INSTRUMENT feature added in ClickHouse#89173, the values passed to
handlers (LOG, SLEEP, PROFILE) were called 'parameters' in the column
of `system.instrumentation`, the SQL syntax description, internal
type aliases, member names and error messages.

Strictly speaking, parameters are the named placeholders declared in a
function/handler signature, while arguments are the actual values
passed at call time. Since the column stores the values supplied to
the handler (e.g. `[100]` for SLEEP), 'arguments' is the more
accurate term.

This patch renames consistently across:
- `system.instrumentation.parameters` column to `arguments` (and its
  description)
- The SQL syntax block in the `SYSTEM INSTRUMENT ADD` documentation:
  `HANDLER [PARAMETERS]` to `HANDLER [ARGUMENTS]`
- Internal C++ type aliases `InstrumentedParameter` to
  `InstrumentedArgument` and `InstrumentParameter` to
  `InstrumentArgument`
- AST/parser members `instrumentation_parameters` to
  `instrumentation_arguments`
- Local variables (`params`/`param` to `args`/`arg`) and error
  messages
- The example output and tests that select the column

Also rewords "the `ALL` parameter" to "the `ALL` keyword" in the
`SYSTEM INSTRUMENT REMOVE` docs, since `ALL` is a SQL keyword.
@clickhouse-gh

clickhouse-gh Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3826458]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) FAIL
04221_dictgetordefault_arrayjoin_80703 FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR consistently renames SYSTEM INSTRUMENT handler values from parameters to arguments across parser/AST/system table/docs and adds parser guards for unsupported and out-of-range literals. One behavior-contract issue remains in SLEEP: extra arguments are silently ignored and inverted ranges are not validated, so the change is not ready to approve yet.

Findings

⚠️ Majors

  • [src/Interpreters/InstrumentationManager.cpp:463-469] SLEEP treats any args.size() > 1 as a two-value range, consuming only args[0] and args[1] and silently ignoring additional arguments. This violates the documented syntax (single value or min max) and can hide user mistakes. The same branch also constructs std::uniform_real_distribution(min, max) without checking min <= max.
    • Suggested fix: reject argument counts other than 1 or 2, and return BAD_ARGUMENTS when min > max.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Enforce SLEEP argument count to exactly 1 or 2.
    2. Reject reversed ranges (min > max) before creating the distribution.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 1, 2026
Comment thread src/Parsers/ParserSystemQuery.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the SYSTEM INSTRUMENT handler value list concept from “parameters” to “arguments” across the user-facing system table/documentation and the internal parser/AST/manager plumbing for the XRay-based instrumentation feature.

Changes:

  • Renamed system.instrumentation.parameters column to arguments and updated system table implementation accordingly.
  • Renamed related parser/AST fields and internal type aliases from *Parameter* to *Argument*.
  • Updated documentation and stateless tests to use the new column name and terminology.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/queries/0_stateless/03643_system_instrumentation_no_suspicious_lowcardinality.sql Updates view creation to select arguments instead of parameters.
tests/queries/0_stateless/03642_system_instrument_add_remove.sh Updates test queries selecting from system.instrumentation to use arguments.
src/Storages/System/StorageSystemInstrumentation.cpp Renames the system table column and output population from parameters to arguments.
src/Parsers/ParserSystemQuery.cpp Renames parser variables/AST field population to instrumentation_arguments.
src/Parsers/ASTSystemQuery.h Renames the AST member/type alias to InstrumentArgument / instrumentation_arguments.
src/Parsers/ASTSystemQuery.cpp Updates formatting to print instrumentation_arguments.
src/Interpreters/InterpreterSystemQuery.cpp Passes instrumentation_arguments to InstrumentationManager::patchFunction.
src/Interpreters/InstrumentationManager.h Renames type alias and stored point field from parameters to arguments.
src/Interpreters/InstrumentationManager.cpp Renames logging/handler logic and stringification from parameters to arguments.
docs/en/sql-reference/statements/system.md Updates SYSTEM INSTRUMENT syntax placeholder to [ARGUMENTS] and rewords ALL as a keyword.
docs/en/operations/system-tables/instrumentation.md Renames documented system table column and example output to arguments.
Comments suppressed due to low confidence (1)

src/Interpreters/InstrumentationManager.cpp:470

  • sleep() treats any args.size() > 1 as a (min, max) pair and silently ignores any extra arguments. The docs describe either 1 value or 2 values; consider validating args.size() is exactly 1 or 2 and throwing a BAD_ARGUMENTS error otherwise. Also consider validating min <= max before constructing uniform_real_distribution to avoid undefined/implementation-defined behavior for inverted ranges.
    if (args.size() == 1)
    {
        duration_ms = static_cast<Int64>(1000 * get_value(args[0]));
    }
    else
    {
        auto min = get_value(args[0]);
        auto max = get_value(args[1]);

        std::uniform_real_distribution<> distrib(min, max);
        duration_ms = static_cast<Int64>(1000 * distrib(random_generator));
    }

Comment thread src/Parsers/ParserSystemQuery.cpp Resolved
Comment thread src/Parsers/ParserSystemQuery.cpp Resolved
Comment thread src/Parsers/ParserSystemQuery.cpp Resolved
pamarcos added 4 commits May 1, 2026 12:25
The parser for `SYSTEM INSTRUMENT ADD` accepts string, integer, and
float literals as arguments, but the error returned when no argument
is provided only mentioned "string literal". This was misleading for
users of the `SLEEP` handler that takes numeric arguments.

Update the wording to list all accepted literal types.

Addresses review comments:
- ClickHouse#103854 (comment)
- ClickHouse#103854 (comment)
The argument parsing loop in `SYSTEM INSTRUMENT ADD` only handled
`String`, `Int64`, `UInt64` and `Float64` literals. Any other
literal type (e.g. `NULL`) was consumed by the inner `ParserLiteral`
without being added to `instrumentation_arguments` and without
producing a parse error, leading to confusing follow-up failures.

Add an explicit `else` branch that fails the parse with a clear
`expected` message when an unsupported literal type is encountered,
plus a regression test for `NULL`.

Addresses review comment:
- ClickHouse#103854 (comment)
`InstrumentedArgument` stores integers as `Int64`, but the parser
also accepts non-negative integer literals which the lexer produces as
`UInt64`. A `static_cast<Int64>` of a `UInt64` value larger than
`Int64::max` silently wraps around to a negative number, e.g. passing
`9223372036854775808` to the `SLEEP` handler ended up being
interpreted as a negative duration.

Range-check the `UInt64` value before the cast and emit a clear parse
error when it does not fit in `Int64`. Add a regression test.

Addresses review comment:
- ClickHouse#103854 (comment)
The error thrown when the LOG handler is given the wrong number of
arguments was generic ("Expected exactly one argument for
instrumentation"), which is harder to interpret when multiple
handlers are configured for the same function. Make it explicit that
this check belongs to the LOG handler.

Addresses review comment:
- ClickHouse#103854 (comment)
@pamarcos
pamarcos marked this pull request as ready for review May 5, 2026 14:57
duration_ms = static_cast<Int64>(1000 * get_value(params[0]));
duration_ms = static_cast<Int64>(1000 * get_value(args[0]));
}
else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SLEEP still accepts any number of literals greater than 1, but this branch only consumes args[0] and args[1] and silently ignores extras. That breaks the documented contract (single duration or min max range) and can hide user mistakes like accidentally passing a third value.

Could we validate args.size() == 1 || args.size() == 2 and throw BAD_ARGUMENTS otherwise? While touching this branch, please also reject min > max before constructing std::uniform_real_distribution, because the standard requires min <= max.

@clickhouse-gh

clickhouse-gh Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 79.25% (84/106) | lost baseline coverage: 1 line(s) · Uncovered code

Full report · Diff report

@pamarcos
pamarcos added this pull request to the merge queue May 27, 2026
Merged via the queue into ClickHouse:master with commit 5e67948 May 27, 2026
321 of 326 checks passed
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @pamarcos @antonio2368 — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 27, 2026
fastio pushed a commit to fastio/ClickHouse that referenced this pull request May 29, 2026
Reject `SLEEP` instrumentation argument counts other than one or two.

Reject ranges where the minimum is greater than the maximum before constructing the distribution.

ClickHouse#103854 (comment)
fastio pushed a commit to fastio/ClickHouse that referenced this pull request May 29, 2026
Use `formatQuerySingleLine` instead of `EXPLAIN SYNTAX` to test formatter output for `SYSTEM INSTRUMENT ADD` arguments.

Make the reversed `SLEEP` range case explicit and verify failed validation leaves no matching instrumentation point behind.

ClickHouse#105939

ClickHouse#103854 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants