Skip to content

Do not fail internal system-log ALTER when the metadata exceeds max_query_size - #111703

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix/system-log-readonly-alter-max-query-size
Jul 24, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix/system-log-readonly-alter-max-query-size

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

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

The internal ALTER TABLE ... MODIFY SETTING table_readonly that marks a rotated system log table as readonly no longer fails with QUERY_IS_TOO_LARGE when the table's metadata exceeds max_query_size (as system.metric_log's metadata now does).

Description

The metadata of system.metric_log has outgrown the default max_query_size (273438 bytes vs 262144), so the internal ALTER TABLE ... MODIFY SETTING table_readonly issued when a rotated system log table is marked readonly fails with QUERY_IS_TOO_LARGE and logs an Error on every rotation:

SystemLog (system.metric_log): Failed to mark the rotated system log table as readonly; continuing with rotation: Code: 229. DB::Exception: The resulting metadata of table system.metric_log_0 (273438 bytes) would exceed max_query_size (262144), which would make the table unloadable.

Since the 26.7 → 26.8 version cut this makes the Error message in clickhouse-server.log test of the Upgrade check red on unrelated PRs (observed on at least 7 different PRs on 2026-07-23, per CIDB).

Loading table metadata at startup parses it with an unlimited query size (DatabaseOnDisk::parseQueryFromMetadata passes max_query_size = 0 to tryParseQuery), so the size validation in DatabaseOrdinary::alterTable is not needed for this internally generated query. Disable max_query_size for the Alter query kind in SystemLog::addSettingsForQuery, next to the existing internal-query relaxations for Insert and Rename.

Report where this was observed: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101039&sha=0d8a6d9170b529147c77cfc038993a22b4f4fae9&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29

Related: #101039
Related: #95079

Version info

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

…x_query_size`

The metadata of `system.metric_log` has outgrown the default
`max_query_size` (273438 bytes vs 262144), so the internal
`ALTER TABLE ... MODIFY SETTING table_readonly` issued when a rotated
system log table is marked readonly started to fail with
`QUERY_IS_TOO_LARGE`, logging an `Error` on every rotation:

    SystemLog (system.metric_log): Failed to mark the rotated system log
    table as readonly; continuing with rotation: Code: 229. DB::Exception:
    The resulting metadata of table system.metric_log_0 (273438 bytes)
    would exceed max_query_size (262144), which would make the table
    unloadable.

This makes the Upgrade check red on every PR since the 26.7 -> 26.8
version cut (observed on at least 7 unrelated PRs on 2026-07-23).
Loading table metadata at startup parses it with an unlimited query
size, so the validation is not needed for this internally generated
query: disable `max_query_size` for the `Alter` query kind in
`SystemLog::addSettingsForQuery`.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101039&sha=0d8a6d9170b529147c77cfc038993a22b4f4fae9&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29
Related: #101039

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5c7da5a]

Summary: ✅


AI Review

Summary

This PR disables max_query_size only for the internal system-log ALTER that marks rotated tables as read-only. I traced that path through SystemLog, StorageMergeTree, and DatabaseOrdinary, checked the current PR discussion and CI state, and did not find a correctness, compatibility, or rollout issue in the current patch.

Final Verdict

✅ No new findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 23, 2026
@Algunenano Algunenano self-assigned this Jul 24, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this was caused by #108283

alexey-milovidov added a commit to niyue/ClickHouse that referenced this pull request Jul 25, 2026
…olumn-matcher

Pulls in the fixes for the unrelated Upgrade check failures: ClickHouse#111671 (move `join_runtime_filter_min_probe_rows` settings-history entry to the correct section) and ClickHouse#111703 (fix `metric_log` rotation readonly-ALTER exceeding `max_query_size`).
Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105045&sha=d406cf6a81dd0a897336361b40986a51245de652&name_0=PR
CheSema added a commit that referenced this pull request Jul 27, 2026
… 26.7

The 26.7 release shipped only the extracted subset (use_reader_executor,
long connections, min_bytes_for_seek, max_tail_for_drain at 1 MiB); the
history entries claiming 26.7 for the rest are false against the
released binary and fail the Upgrade check. Move the six query settings
and the four merge_reader_executor_* MergeTree settings to 26.8 blocks,
correct the 26.7 max_tail_for_drain entry to the shipped 1 MiB default,
and record its 26.8 change to 512 KiB.

The remaining Upgrade check error (system.metric_log rotation metadata
exceeding max_query_size) is master's own overshoot, fixed upstream by
#111703 - it resolves at
the next master merge.

Upgrade check: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103706&sha=db1d34500b14b171117092618c8756b43ab26482&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…eadonly-alter-max-query-size

Do not fail internal system-log ALTER when the metadata exceeds max_query_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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