Skip to content

Lower the log level of the PK binary-search messages to Test - #110324

Merged
alexey-milovidov merged 23 commits into
masterfrom
lower-binary-search-log-level
Aug 2, 2026
Merged

alexey-milovidov merged 23 commits into
masterfrom
lower-binary-search-log-level

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

The per-part binary-search messages emitted by MergeTreeDataSelectExecutor during primary key analysis are very verbose. They are printed for every part and every boundary of every query that uses the binary search on the primary key index:

  • Running binary search on index range for part ... (... marks)
  • Found (LEFT) boundary mark: ...
  • Found (RIGHT) boundary mark: ...

At the default trace level they flood the server log while rarely being useful in day-to-day operation. This lowers them from Trace to Test, so they are only emitted when logging is explicitly turned up.

Because test is the highest verbosity level, this change also aligns the surfaces that expose log levels to clients so the messages remain discoverable:

  • test is now listed among the valid values of the send_logs_level setting and in the Native protocol spec (docs/en/interfaces/specs/NativeProtocol.md).
  • The gRPC LogsLevel schema gains LOG_TEST = 9 to match what the server already emits for test-level entries.
  • The sparse primary indexes guide notes that these three messages now require test-level logging.

Changelog category (leave one):

  • Improvement

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

Reduced the verbosity of the per-part primary-key binary-search diagnostics in MergeTree by lowering them from trace logging to test logging.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.8.1.639 (included in 26.8 and later)

The per-part binary-search messages emitted by `MergeTreeDataSelectExecutor`
during primary key analysis (`Running binary search on index range for part
...`, `Found (LEFT) boundary mark: ...`, `Found (RIGHT) boundary mark: ...`)
are very verbose: they are printed for every part and every boundary of every
query that uses the binary search on the index. At the default `trace` level
they flood the server log without being useful in the common case.

Lower them from `Trace` to `Test` so they are only visible when explicitly
enabled.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8a1a190]

Summary: ✅


AI Review

Summary

This PR lowers the per-part primary-key binary-search diagnostics in MergeTreeDataSelectExecutor from trace to test, and updates the client-facing surfaces that need to stay consistent with that choice: send_logs_level documentation, the Native protocol spec, the gRPC LogsLevel schema, the generated Python gRPC binding, the system.text_log column description, and the sparse primary indexes guide. I found no remaining correctness, compatibility, or documentation-contract gaps in the current head, and the latest Praktika report for PR 110324 is fully green.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 13, 2026
alexey-milovidov and others added 5 commits July 14, 2026 16:10
The PK binary-search diagnostics in `MergeTreeDataSelectExecutor` were
lowered from `Trace` to `Test`, so they are now only surfaced at the
highest (`test`) verbosity. `test` is already an accepted value of the
`LogsLevel` setting enum (`send_logs_level` is parsed via `magic_enum`),
but it was missing from the documented list of valid values, both in the
`send_logs_level` description and in the Native protocol spec.

List `test` explicitly so the highest client log level is discoverable.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The gRPC `LogsLevel` enum stopped at `LOG_TRACE = 8`, but `GRPCServer`
maps a log entry's Poco priority directly onto this enum via
`set_level(static_cast<grpc::LogsLevel>(...))`. Any `test`-level message
(`Poco::Message::PRIO_TEST == 9`) already produced an out-of-schema
value, and lowering the PK binary-search diagnostics to `Test` adds more
such messages when a gRPC client requests `send_logs_level='test'`.

Declare `LOG_TEST = 9` so the published schema matches what the server
emits, and add a matching `static_assert` next to the existing ones.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The sparse primary indexes guide instructs readers to enable trace
logging to observe the `Running binary search on index range`,
`Found (LEFT) boundary mark`, and `Found (RIGHT) boundary mark` messages.
These were lowered to the `test` level, so add a note explaining how to
raise the verbosity to `test` to see them, while leaving the rest of the
version-pinned example (which is still logged at `trace`) intact.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`docs/reference/settings/session-settings.mdx` mirrors the `send_logs_level`
docstring, so add `test` to its valid-values list to keep the generated
documentation consistent with `src/Core/Settings.cpp`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements and removed pr-ci labels Jul 14, 2026
@mintlify

mintlify Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 14, 2026, 4:36 PM

…examples in the guide

The AI review noted that only the first PK binary-search example mentioned
that the `Running binary search on index range` and `Found (LEFT)/(RIGHT)
boundary mark` messages are now logged at the `test` level. Make the note
global and reference it from the secondary-table, materialized-view, and
projection examples that show the same messages.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The two CI failures on commit 31b2f1c are unrelated to this PR (a log-level and documentation change):

Merged master and addressed the remaining AI review finding (the test log-level note now covers all binary-search examples in the sparse-primary-indexes guide); a fresh CI run is in progress.

Address review: utils/grpc-client/pb2/clickhouse_grpc_pb2.py and
clickhouse_grpc_pb2_grpc.py were generated before `LOG_TEST` was added
to clickhouse_grpc.proto, so the bundled Python gRPC client could not
reference clickhouse_grpc_pb2.LOG_TEST. Reran
utils/grpc-client/generate_pb2.py as its own comment instructs after
any change to the .proto file.
…rotocol spec

docs/en/interfaces/specs/NativeProtocol.md and
docs/reference/settings/session-settings.mdx already listed `test` as
a valid `send_logs_level` value, but the Mintlify copy of the Native
protocol spec at docs/reference/interfaces/specs/NativeProtocol.mdx
still stopped at `trace`, leaving that doc surface stale.
…rsion

The previous regeneration used `grpcio-tools` 7.35.0, whose generated
code imports `google.protobuf.runtime_version`, a module only present
in `protobuf` 5.26+. The stateless-test Docker image pins
`protobuf==4.25.8` (`ci/docker/stateless-test/requirements.txt`), so
`03203_grpc_protocol` failed with `ImportError: cannot import name
'runtime_version' from 'google.protobuf'`.

Regenerated `clickhouse_grpc_pb2.py`/`clickhouse_grpc_pb2_grpc.py`
using `grpcio-tools==1.62.3`, which matches the `protobuf` 4.25.x
generation format the previously checked-in files used, and verified
the import against the exact `protobuf==4.25.8`/`grpcio==1.66.2`
versions pinned for CI.
Comment thread src/Core/Settings.cpp Resolved
…lumn description

The `level` column of `system.text_log` already exposes `Test = 9` in its
`Enum8` type, but the column description (and the docs generated from it)
stopped at `8 or 'Trace'`. Append `9 or 'Test'` to the description in
`TextLog.cpp` and to the autogenerated sections of the `text_log` docs.
Comment thread src/Core/Settings.cpp Resolved
…-logs.mdx`

The settings docs were split into per-group pages on master ("Flatten
generated settings groups"), regenerating them from master's
`src/Core/Settings.cpp` — which dropped the `test` value this PR adds
to the `send_logs_level` docstring. Sync the generated page with the
updated source docstring.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov alexey-milovidov added the pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard label Jul 24, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI status on adae312dac3 and actions taken (new head 38c99abef8a):

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110324&sha=adae312dac3ede20f1516467db059154d56ae46a&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

This is the known regression from #100992 (that PR added VersionInfo/txn_version.txt parsing during part loading). 04241_part_loading_tree_rollback_contains.sh detaches t_plt_rb_contains non-permanently while fabricating parts out of band, so a stress restart reloads the table and races the script on txn_version.txt, corrupting it (the duplicated version: 1 prefix) and producing Code: 27 at startup.

Already tracked and fixed: issue #111053 and PR #111055 ("Detach tables permanently in part-loading-tree rollback tests", merged 2026-07-23, Closes #111053), which switches all four rollback tests including 04241 to DETACH ... PERMANENTLY. The failing arm_asan_ubsan,s3 run (sha adae312) does not include that fix yet; a master rebase picks it up. No separate PR needed; unrelated to #110324.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged master to pull in the merged fixes for the unrelated reds on 38c99abef8a: #111671 (the join_runtime_filter_min_probe_rows settings-history entry that made Upgrade check fail on every PR) and #111055 (the 04241_part_loading_tree_rollback_contains stress restart failure). The remaining Upgrade check sub-failure — the system.metric_log "would exceed max_query_size" error message in the server log — is unrelated to this PR and is addressed by the open PR #111703.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI status for d2f8f55: the previous Upgrade check red cleared after the last master merge. The two remaining failures are unrelated to this logging-only change, both with fixes in progress:

CH Inc sync failed on a Cloud-only stateless job in the sync PR — rerun triggered.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110324&sha=d2f8f55047f7b92ee0eb4ff2e45f80b7da09fc76&name_0=PR

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged `master` again (clean) to pull in the fixes for the two unrelated CI failures from the previous run:

Rebuilt the four affected translation units locally (clean). Fresh CI is running on `a7ce0b00370`.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI on a7ce0b00370 finished: 148 success / 24 skipped / 2 real failures, both unrelated to this logging-only diff.

Nothing to change here; both reds clear once those fixes merge. Also replied to the docs-translation review nit: docs/ru, docs/zh, docs/ko, docs/ar, docs/pt-BR are generated from the English pages (see docs/README.md), so they are not edited by hand in a PR.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged master again (head cdea7131704).

Since the previous run, the fix for the Stress test (arm_debug) red — #109023 (Inconsistent KeyCondition behavior for wider-typed key comparisons, issue #111421) — merged into master (107980ea2e3, verified as an ancestor of this branch), so that failure should clear on the fresh run.

The other red, Upgrade check (amd_release) (Code: 27 Cannot parse input from AsyncLoader::worker while reading object-storage metadata of the parts fabricated by the 04*_part_loading_tree_rollback_* tests), is issue #111053; its fix #111922 is still open, so that one may persist until it lands.

The PR's own diff is unchanged (12 files, logging level + docs/gRPC surfaces); the four affected translation units rebuild cleanly.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI on cdea7131704 finished: the previous reds are gone — the last master merge cleared Stress test (arm_debug) (#109023 is in) and Upgrade check (amd_release). The sole remaining failure is Stress test (amd_debug): Logical error: 'Virtual row boundary violated in MergingSortedAlgorithm ...' — a pre-existing read-in-order virtual-row bug on master (it hits roughly one unrelated PR per day since 2026-07-14 per CIDB; this PR is a logging-only diff with no path into the merge algorithm). Tracking: #106740 (recurred after being closed), umbrella #106630. Fix in progress: #111457 (open, not yet merged, so re-merging master would not clear this red).

@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 30/30 (100.00%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 2, 2026
@alexey-milovidov alexey-milovidov self-assigned this Aug 2, 2026
Merged via the queue into master with commit 945e665 Aug 2, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the lower-binary-search-log-level branch August 2, 2026 16:14
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 2, 2026

This branch was successfully deployed

1 active deployment
staging - docs — 8a1a1903 Deployed Aug 2, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard 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.

3 participants