Skip to content

Follow up changes for setting table_readonly - #100950

Merged
github-merge-queue[bot] merged 3 commits into
ClickHouse:masterfrom
alesapin:followup-fix-readonly
Jun 12, 2026
Merged

github-merge-queue[bot] merged 3 commits into
ClickHouse:masterfrom
alesapin:followup-fix-readonly

Conversation

@alesapin

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

ClickHouse throws proper exception for attempts to use table_readonly for replicated engines. Also better exception handling for DDL queries (and DatabaseReplicated) related to this setting. Followup to #97652.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4f659ef]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_llvm_coverage, 2/5) failure
test_overcommit_tracker/test.py::test_user_overcommit FAIL cidb
Stress test (amd_tsan) failure
ThreadSanitizer: data race (STID: 2604-385d) FAIL cidb
Stress test (arm_debug) failure
Logical error: No available columns (STID: 3938-33a6) FAIL cidb
Stress test (arm_msan) failure
Test script failed FAIL cidb

AI Review

Summary

This PR hardens handling around table_readonly: it rejects this setting for ReplicatedMergeTree at both CREATE TABLE and ALTER ... MODIFY SETTING, and fixes distributed DDL retry behavior so TABLE_IS_READ_ONLY from non-replicated tables is treated as non-retriable. I did not find correctness, safety, concurrency, or compatibility issues in the patch itself.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ✅
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Mar 27, 2026
Comment thread src/Interpreters/DDLWorker.cpp Outdated
{
if (auto * query_with_table = dynamic_cast<ASTQueryWithTableAndOutput *>(task.query.get()))
{
auto table_id = context->tryResolveStorageID(*query_with_table, Context::ResolveOrdinary);

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.

tryResolveStorageID here uses the server-level context, not the per-task query context. For ON CLUSTER statements with an unqualified table name, this can resolve against the wrong default database (often default), fail to find the storage, and keep TABLE_IS_READ_ONLY retriable.

That reintroduces retry loops for non-replicated tables outside default.

Please resolve table id using the same context as query execution (task.makeQueryContext(...) / task default DB) before checking supportsReplication, so retry classification is deterministic.

@clickhouse-gh

clickhouse-gh Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.20% +0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.70% 76.80% +0.10%

Changed lines: 100.00% (39/39) · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

e.code() != ErrorCodes::TOO_MANY_SIMULTANEOUS_QUERIES &&
e.code() != ErrorCodes::MEMORY_LIMIT_EXCEEDED;

/// TABLE_IS_READ_ONLY is retriable for ReplicatedMergeTree (temporary ZooKeeper disconnect),

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.

This code fragment looks like a kludge. The right way will be - having two error codes: TABLE_IS_READ_ONLY and TABLE_IS_PERMANENTLY_READ_ONLY.

@alexey-milovidov alexey-milovidov self-assigned this Apr 8, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Let's describe the reason - why ReplicatedMergeTree tables can't be permanently readonly.

@alexey-milovidov

Copy link
Copy Markdown
Member

Superseded by #105109, which addresses @alexey-milovidov's review feedback by introducing a dedicated TABLE_IS_PERMANENTLY_READ_ONLY error code instead of the runtime kludge in DDLWorker.

alexey-milovidov added a commit that referenced this pull request May 16, 2026
Some authors don't want this kind of automated help on their PRs. Pre-
filter the involves set on `author.login` against a configurable
`SKIP_AUTHORS` array (initially just `alesapin`), applied right after
the backport filter so all three downstream filters (authored, assigned,
taken-over) honour it.

NB: the jq predicate binds `.author.login as $a` first, otherwise the
subsequent `$skip | index(.author.login)` would evaluate `.author.login`
against `$skip` (an array) and fail with "Cannot index array with
string".

Verified live: 426 involves -> 415 after both filters, with the two
alesapin PRs (`#100950 Follow up changes for setting table_readonly`,
`#99933 Do automatic partitions pruning for mutations when it's
possible`) correctly identified for skipping.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-merge-queue
github-merge-queue Bot merged commit 31120da into ClickHouse:master Jun 12, 2026
156 of 160 checks passed
pull Bot pushed a commit to SINHASantos/ClickHouse that referenced this pull request Jun 12, 2026
`TABLE_IS_READ_ONLY` was overloaded for both transient (`ReplicatedMergeTree`
in temporary read-only state due to ZooKeeper disconnect) and permanent
(`table_readonly` setting, static storage) cases. `DDLWorker` retries it
indefinitely, which is correct for the transient case but caused `OPTIMIZE
TABLE ON CLUSTER` to hang when `table_readonly = 1`.

Replace the kludge in `DDLWorker::tryExecuteQuery` (which classified by
resolving the storage and probing `supportsReplication`) with a clean
split: `TABLE_IS_READ_ONLY` stays retriable; `TABLE_IS_PERMANENTLY_READ_ONLY`
is non-retriable and is thrown by `assertNotReadonly` and `isStaticStorage`
sites in `StorageMergeTree`, `StorageReplicatedMergeTree`, and the four
DML interpreters (`ALTER`, `DELETE`, `UPDATE`, `DROP TRUNCATE`).

Updates the existing tests that exercised these throw sites
(`s3_plain`, `readonly` disk, `table_disk`, `table_readonly`) to expect
the new error code.

Addresses review feedback on ClickHouse#100950.
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 12, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Some authors don't want this kind of automated help on their PRs. Pre-
filter the involves set on `author.login` against a configurable
`SKIP_AUTHORS` array (initially just `alesapin`), applied right after
the backport filter so all three downstream filters (authored, assigned,
taken-over) honour it.

NB: the jq predicate binds `.author.login as $a` first, otherwise the
subsequent `$skip | index(.author.login)` would evaluate `.author.login`
against `$skip` (an array) and fail with "Cannot index array with
string".

Verified live: 426 involves -> 415 after both filters, with the two
alesapin PRs (`ClickHouse#100950 Follow up changes for setting table_readonly`,
`ClickHouse#99933 Do automatic partitions pruning for mutations when it's
possible`) correctly identified for skipping.

Co-Authored-By: Claude Opus 4.7 (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.

3 participants