Skip to content

Remove strange trash (again) - #108657

Merged
alexey-milovidov merged 6 commits into
masterfrom
remove-strange-trash-again
Jun 30, 2026
Merged

alexey-milovidov merged 6 commits into
masterfrom
remove-strange-trash-again

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Related: #68748
Related: #68979
Related: #52503

The automatic value of max_threads (and friends: max_final_threads, max_parsing_threads, max_part_loading_threads, ...) has for years been shown in system.settings like this:

┌─name────────┬─value─────┐
│ max_threads │ 'auto(8)' │
└─────────────┴───────────┘

Note the single quotes. They are inside the value - a String column carrying the literal characters 'auto(8)'. This is strange trash.

A short history of the strange trash, in three acts:

  • Act I. In 2023 I removed the quotes in a commit titled, with great restraint, "Fix strange trash".
  • Act II. @thevar1able promptly put the trash back in Revert "Fix strange trash" #68979 (branch put-strange-trash-back, commit "Revert "Fix strange trash""). In fairness, he was right: at that moment the parser only recognized the quoted form, so a new un-quoted server choked on the 'auto(N)' that older replicas send over the wire - settings travel between servers as their string representation and are re-parsed - and mixed-version clusters broke (Incorrect parsing of setting value between mixed versions #68748).
  • Act III (this PR). The obstacle is gone. stringToMaxThreads now accepts both auto(N) and the legacy 'auto(N)'. So we can finally emit the clean form while still understanding the quoted form an older replica sends, and every released version can already parse the un-quoted form we send. The strange trash goes back out - and this time the tolerant parser stays, so it stays out for good.

The result:

┌─name────────┬─value───┐
│ max_threads │ auto(8) │
└─────────────┴─────────┘

What's included:

  • SettingFieldMaxThreads::toString returns auto(N) without quotes.
  • A comment on stringToMaxThreads explaining the quoted form must remain parseable (it is the mixed-version-cluster compatibility guarantee).
  • Tests 04202_set_default_preserves_max_threads_auto and test_cgroup_limit updated to the clean form.
  • The upgrade check (upgrade_runner.sh) now ignores auto(...) values when diffing settings against the previous release, so the rendering change is not reported as a setting change.
  • The system.settings example in the docs updated.

Changelog category (leave one):

  • Improvement

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

The automatic value of max_threads and similar settings is now shown in system.settings as auto(8) instead of 'auto(8)'; the surrounding single quotes were a long-standing artifact baked into the value. Cross-version compatibility is preserved: the legacy quoted form is still accepted when parsing settings received from older servers.

Documentation entry for user-facing changes

  • Documentation is written (the system.settings example in docs/en/operations/settings/overview.md is updated)

Version info

  • Merged into: 26.7.1.281 (included in 26.7 and later)

The automatic value of settings like `max_threads` shows up in
`system.settings` as `'auto(64)'` - with literal single quotes baked
right into the string value. They are pure garbage and have annoyed me
for years.

Back in 2023 I removed them in a commit titled, with great restraint,
"Fix strange trash". Konstantin promptly put the trash back in #68979
(branch `put-strange-trash-back`, commit "Revert \"Fix strange trash\"").
And, in fairness, he was right at the time: the parser only understood
the quoted form, so a new un-quoted server could not parse the
`'auto(N)'` that older replicas send over the wire as a setting string,
which broke mixed-version clusters (#68748).

That obstacle is now gone. `stringToMaxThreads` accepts both `auto(N)`
and the legacy `'auto(N)'`, so emitting the clean form is safe in both
directions: an old replica's quoted value is still parsed by us, and
every released version can already parse the un-quoted value we now
send. So the strange trash goes back out - and this time the tolerant
parser stays, so it stays out for good.

Changes:
- `SettingFieldMaxThreads::toString` now returns `auto(N)` without quotes.
- Documented why `stringToMaxThreads` must keep accepting the legacy
  quoted form (it is the mixed-version-cluster compatibility guarantee).
- Updated test `04202_set_default_preserves_max_threads_auto` and the
  `test_cgroup_limit` integration test to match the clean form.
- The upgrade check (`upgrade_runner.sh`) now ignores `auto(...)` values
  when diffing settings against the previous release, so the
  quoted-vs-unquoted rendering is not reported as a setting change.
- Updated the `system.settings` example in the docs.

Related: #68748
Related: #68979
Related: #52503

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

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [66c396f]

Summary: ✅


AI Review

Summary

This PR changes SettingFieldMaxThreads string rendering from the legacy quoted 'auto(N)' value to the clean auto(N) form while keeping both forms parseable for mixed-version settings exchange. The current revision addresses the prior upgrade-check over-filtering concern and adds focused coverage for clean and legacy parsing, so I do not have new inline findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 26, 2026
Comment thread tests/docker_scripts/upgrade_runner.sh Resolved
…ifference

Address review (AI Review "Request changes"): the upgrade settings-history
check excluded every changed setting whose new value contained `auto(`
(`new_value NOT LIKE '%auto(%'`). That is broader than the intended
quoted-to-unquoted rendering change, so a genuine default change to an
`auto(N)` value (e.g. `4` -> `auto(8)`, or a brand-new auto-defaulted
setting) could escape the required `SettingsChangesHistory.cpp` entry.

Suppress only the pure rendering difference: a row where the old value is
exactly the new value wrapped in single quotes (the legacy `'auto(N)'` form).
A genuine change of an auto-valued setting's default is still reported.
Applied to both the `system.settings` and `system.merge_tree_settings`
queries.

Verified with `clickhouse-local` that the new condition drops the
quote-only difference and keeps genuine changes and brand-new auto settings.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Core/SettingsFields.cpp Resolved
alexey-milovidov and others added 2 commits June 28, 2026 23:40
The cross-version compatibility guarantee of this change is that
`stringToMaxThreads` keeps accepting both the clean `auto(N)` form and
the legacy `'auto(N)'` form (single quotes baked into the string value)
that older replicas send over the wire. The existing tests only assert
the new `system.settings` display form, so a regression that drops the
`startsWith(str, "'auto")` branch in `stringToMaxThreads` would still
pass while silently breaking mixed-version clusters.

The new test `04416_max_threads_auto_parsing_compat` feeds both forms
through the parsing path (`SET max_threads = 'auto(8)'` and the legacy
`SET max_threads = '''auto(8)'''`) and asserts the setting stays auto and
renders without quotes, across the `SettingFieldMaxThreads` family. If the
legacy branch is removed, `SET max_threads = '''auto(8)'''` throws a parse
error and the test fails loudly.

Addresses review feedback on
#108657

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov added a commit that referenced this pull request Jun 29, 2026
The in-flight PR #108657 already claims `04416` (`04416_max_threads_auto_parsing_compat`),
so move the atomic-populate tests off it to the next free pair (`04418`/`04419`) and update
the internal `create_err` temp-file reference.
After merging master, `04416_max_threads_auto_parsing_compat` collided
with several `04416_*` tests added on master. Renumber it to the next
free number (`04489`).
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged the latest master (the branch was ~290 commits behind and the only red was unrelated) and renumbered the new regression test from 04416_max_threads_auto_parsing_compat to 04489_… to avoid a collision with several 04416_* tests added on master. The SettingsFields.cpp change is unchanged and was re-verified to compile against the merged tree.

The sole CI failure — Upgrade check (amd_release) → Error message in clickhouse-server.log — is not caused by this PR. It is the Value passed to 'throwIf' function is non-zero (FUNCTION_THROW_IF_VALUE_IS_NON_ZERO) error logged by the intentionally-failing async mutation in the stateless test 04341_broken_mutation_part_log_flush, which leaks into the upgrade log because it is a plain-MergeTree mutation not covered by the existing MutateFromLogEntryTask allowlist entry. It is hitting ~19 unrelated pull requests over the last four days (confirmed via play.clickhouse.com). Fix submitted separately: #108856

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 6/6 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov merged commit 2f47999 into master Jun 30, 2026
173 of 174 checks passed
@alexey-milovidov
alexey-milovidov deleted the remove-strange-trash-again branch June 30, 2026 05:03
@alexey-milovidov alexey-milovidov self-assigned this Jun 30, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 30, 2026
pull Bot pushed a commit to Mu-L/ClickHouse that referenced this pull request Jul 1, 2026
…part_log_flush`

The stateless test `04341_broken_mutation_part_log_flush` runs an
intentionally-failing async mutation
`ALTER TABLE ... UPDATE x = x + throwIf(1) WHERE 1` (expecting
`serverError UNFINISHED`) to assert that the failed `MutatePart`
`part_log` entry is flushed before the failure is reported to the client.

After the upgrade restart the broken mutation is retried in the
background and logs `Value passed to 'throwIf' function is non-zero`
(`FUNCTION_THROW_IF_VALUE_IS_NON_ZERO`, Code: 395) to
`clickhouse-server.upgrade.log`, which fails the `Upgrade check` with
`Error message in clickhouse-server.log (see upgrade_error_messages.txt)`.

This is the expected test-induced error, not a backward incompatibility
or a regression - exactly the same class as the `CANNOT_PARSE_TEXT`
mutation errors already allowlisted (issue ClickHouse#39174). Note the table uses
a plain `MergeTree`, so the error is emitted by `MutatePlainMergeTreeTask`
and is not covered by the existing `MutateFromLogEntryTask` exclusion.
`throwIf` only raises when a query explicitly calls it with a truthy
argument, so the message can only come from such a test, never from an
upgrade incompatibility; the narrow message substring also covers the
wrapping `MergeTreeBackgroundExecutor` line.

The failure is not caused by any product change - it surfaces on any
pull request that runs the Upgrade check. Observed master-wide on ~19
distinct pull requests over the four days 2026-06-26..2026-06-29
(confirmed via play.clickhouse.com `checks` history), e.g. PR ClickHouse#108657.

This mirrors the earlier allowlist additions for `04338` ('x'),
`01414` ('Hello') and `00834` ('a'/'b').

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The cross-version compatibility guarantee of this change is that
`stringToMaxThreads` keeps accepting both the clean `auto(N)` form and
the legacy `'auto(N)'` form (single quotes baked into the string value)
that older replicas send over the wire. The existing tests only assert
the new `system.settings` display form, so a regression that drops the
`startsWith(str, "'auto")` branch in `stringToMaxThreads` would still
pass while silently breaking mixed-version clusters.

The new test `04416_max_threads_auto_parsing_compat` feeds both forms
through the parsing path (`SET max_threads = 'auto(8)'` and the legacy
`SET max_threads = '''auto(8)'''`) and asserts the setting stays auto and
renders without quotes, across the `SettingFieldMaxThreads` family. If the
legacy branch is removed, `SET max_threads = '''auto(8)'''` throws a parse
error and the test fails loudly.

Addresses review feedback on
ClickHouse#108657

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…part_log_flush`

The stateless test `04341_broken_mutation_part_log_flush` runs an
intentionally-failing async mutation
`ALTER TABLE ... UPDATE x = x + throwIf(1) WHERE 1` (expecting
`serverError UNFINISHED`) to assert that the failed `MutatePart`
`part_log` entry is flushed before the failure is reported to the client.

After the upgrade restart the broken mutation is retried in the
background and logs `Value passed to 'throwIf' function is non-zero`
(`FUNCTION_THROW_IF_VALUE_IS_NON_ZERO`, Code: 395) to
`clickhouse-server.upgrade.log`, which fails the `Upgrade check` with
`Error message in clickhouse-server.log (see upgrade_error_messages.txt)`.

This is the expected test-induced error, not a backward incompatibility
or a regression - exactly the same class as the `CANNOT_PARSE_TEXT`
mutation errors already allowlisted (issue ClickHouse#39174). Note the table uses
a plain `MergeTree`, so the error is emitted by `MutatePlainMergeTreeTask`
and is not covered by the existing `MutateFromLogEntryTask` exclusion.
`throwIf` only raises when a query explicitly calls it with a truthy
argument, so the message can only come from such a test, never from an
upgrade incompatibility; the narrow message substring also covers the
wrapping `MergeTreeBackgroundExecutor` line.

The failure is not caused by any product change - it surfaces on any
pull request that runs the Upgrade check. Observed master-wide on ~19
distinct pull requests over the four days 2026-06-26..2026-06-29
(confirmed via play.clickhouse.com `checks` history), e.g. PR ClickHouse#108657.

This mirrors the earlier allowlist additions for `04338` ('x'),
`01414` ('Hello') and `00834` ('a'/'b').

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.

2 participants