Repository navigation
Enforce allow_non_metadata_alters on the mutation path, and document what it blocks - #115287
alexey-milovidov merged 18 commits into
Conversation
allow_non_metadata_alters is documented as a switch against ALTERs that rewrite data on disk, but it only rejected the AlterCommand-shaped subset. InterpreterAlterQuery::parseAlterCommandSegments classifies UPDATE, DELETE, MATERIALIZE INDEX/PROJECTION/STATISTICS/COLUMN/TTL, APPLY DELETED MASK, APPLY PATCHES and REWRITE PARTS as MutationCommands, and that branch calls checkMutationIsPossible, whose Settings parameter MergeTreeData left unused. So the setting was never consulted for the statements that most obviously rewrite parts, and each of them still queued a system.mutations entry. Name the parameter and reject when the commands are non-empty mutations, reusing MutationCommands::hasNonEmptyMutationCommands so the rejected set stays in sync with the set that would actually be mutated. Plain DELETE FROM re-enters this path, because lightweight_delete_mode defaults to ALTER_UPDATE and InterpreterDeleteQuery synthesizes ALTER TABLE ... UPDATE _row_exists = 0. The storage cannot distinguish that from a user-written statement of the same shape: both arrive as a MutationCommand of type UPDATE with identical ast_text, and there is no provenance field. Exempting it by shape would therefore reopen the hole for ALTER ... UPDATE, so the exemption is set by the synthesizing interpreter on the private context copy it already builds for mutations_sync, which no user-typed query can reach. Measured on a debug build, allow_non_metadata_alters = 0: all ten mutation forms plus a user-written _row_exists assignment now fail with ALTER_OF_COLUMN_IS_FORBIDDEN and succeeded before; DELETE FROM, lightweight UPDATE, and metadata-only ALTERs keep working; and with the setting enabled, which is the default, nothing changes. The description also stated neither which statements are refused nor that the check is MergeTree-only, which is the second half of the report. Closes: ClickHouse#115058
Review round 1. The previous commit relaxed allow_non_metadata_alters for the lightweight delete that InterpreterDeleteQuery synthesizes, by setting it on the context copy that branch already builds. That only holds locally: for DELETE FROM ... ON CLUSTER the settings travel in the DDL entry and the worker re-clamps them against its own profile, so an operator who constrains the setting to 0 saw the clustered DELETE refused with ALTER_OF_COLUMN_IS_FORBIDDEN, which contradicts what this change promises. Dispatch the ASTDeleteQuery itself before the ALTER is synthesized, the way InterpreterUpdateQuery already does, so each host re-derives its mode and grants its own relaxation locally and provenance never travels as a setting. StorageWindowView::cleanup() synthesizes an ALTER ... DELETE against its inner AggregatingMergeTree table for the same kind of internal reason, and threadFuncCleanup swallows the exception, so a profile-level 0 would silently stop freeing outdated windows. Grant it the same exemption. Those two are the only InterpreterAlterQuery construction sites outside the interpreter itself. Three corrections to the setting's description, each measured rather than reasoned: DELETE FROM and UPDATE are permitted because the setting governs ALTER DDL and not the dedicated statements, not because they write patch parts, which is false in the default lightweight_delete_mode = alter_update; RENAME COLUMN is refused for any column including an ALIAS, since getMutationStageDecision sets requires_mutation unconditionally for it, unlike DROP COLUMN; and UPDATE is refused as a heavyweight mutation, i.e. under the default alter_update_mode. Tests: pin alter_update_mode and lightweight_delete_mode in the new 01413 section, since the corrections above make both load-bearing, and add an arm asserting that an ALTER UPDATE running as a lightweight update is permitted. The clustered cases need a settings profile, which a stateless test cannot express because the DDL worker reads the default profile rather than the issuing user's, so they go in a two-node integration test instead. That test fails on the previous commit on exactly the two DELETE FROM ... ON CLUSTER cases and passes here, with the four refusal arms green on both.
Shipping the DELETE itself through executeDDLQueryOnCluster lets each host derive its delete mode and its own allow_non_metadata_alters relaxation from its own profile, which a shipped setting cannot do because the worker re-clamps it. But taskShouldBeExecutedOnLeader only leader-routes ASTAlterQuery, ASTOptimizeQuery, ASTDropQuery, ASTCreateIndexQuery and ASTDropIndexQuery, so an ASTDeleteQuery entry ran on every replica of a shard and each local run called mutate(), producing N duplicate Keeper mutation entries for one statement. Before this PR the rewritten ALTER ... ON CLUSTER was an ASTAlterQuery and was leader-routed, so this is a regression this PR would otherwise introduce. The executing leader re-parses the entry with ON CLUSTER stripped, so the local lightweight-delete path with its relaxation is still what runs. ASTUpdateQuery is deliberately left out: UPDATE ... ON CLUSTER already shipped an ASTUpdateQuery and was already absent from that list, so it is pre-existing behaviour and out of scope here. The integration test grows a ReplicatedMergeTree arm. The existing arms use plain MergeTree with a separate INSERT per host, so each node owns private rows and the row-count assertions are satisfied by the faulty per-replica behaviour; with two replicas of one shard and a single INSERT, a doubled mutation becomes observable. It asserts one mutation entry per shard and convergent row counts, and fails with 2 without the routing change.
The clustered DELETE branch added by this PR ships the DELETE statement itself instead of a rewritten ALTER, and InterpreterDeleteQuery has never inlined SQL user-defined functions. At the base of this PR that was harmless, because a clustered DELETE always re-entered an interpreter that does inline before it dispatches: InterpreterAlterQuery for the default lightweight_delete_mode, and InterpreterUpdateQuery for the lightweight_update modes. The new branch returns before either, so the queued entry carried the function call unexpanded. The user-defined function store is not replicated by default, and ON CLUSTER on CREATE FUNCTION is rejected only when it is, so a function legitimately exists on the initiator alone. Such a DELETE then either failed with UNKNOWN_FUNCTION on the hosts where the function is absent, or deleted different rows on hosts where it is defined differently, diverging the replicas of a shard with no error anywhere. validateNonDeterministicMutationsForStorage does not catch that: a function wrapping deterministic functions is itself deterministic. Inline for every DELETE rather than only the clustered one, matching InterpreterUpdateQuery, which inlines unconditionally before its own ON CLUSTER branch. The local path is unaffected: it re-formats the predicate into a synthesized ALTER or UPDATE that the downstream interpreter inlines again, and a second pass is a no-op once no function call remains. Inlining precedes substituteDatabaseInTableFunctions, because a body can itself contain a table function whose database has to be qualified. ASTDeleteQuery::predicate and ::partition are separate pointers to nodes that children also holds, and the class did not override forEachPointerToChild, so the replacement landed in children alone while the member kept pointing at the unexpanded node. formatQueryImpl reads the member, which is what executeDDLQueryOnCluster ships, so the override is what makes the expansion reach the other hosts when the whole predicate is one function call. Two integration arms cover both consequences: a function defined on one host, and a function defined differently on each. Without this commit the first fails with UNKNOWN_FUNCTION from the second host and the second silently deletes different rows on each. During a rolling upgrade of one shard, a clustered DELETE may be picked up by both an old worker, which does not leader-route ASTDeleteQuery and so creates no shard marker, and a new one, which finds the marker absent and executes too. Measured on a mixed two-node cluster in both initiator directions: two identical mutation entries, both completed, no failures, convergent rows, i.e. duplicated work that converges. The two closest precedents for widening this list shipped without a version gate. The description of allow_non_metadata_alters also gains CLEAR INDEX, CLEAR PROJECTION and CLEAR STATISTICS, which set requires_mutation unconditionally; qualifies CLEAR COLUMN as physical-column-only, which is how it behaves; and states that UPDATE is refused whenever it runs as a heavyweight mutation rather than only under the default alter_update_mode.
The two arms that check a DELETE FROM ... ON CLUSTER predicate carrying a SQL user-defined function asserted less than the contract they exist to defend. The contract is that the initiator's function body decides which rows are deleted on every host, but one arm asserted only a row count and the other only that the two hosts agreed with each other. The expansion substitutes arguments positionally, so "the body was inlined but the argument bound wrong" produces a uniformly wrong result that both of those assertions accept. Assert the exact surviving key set on each host instead, which reddens on host divergence and on a uniform wrong answer alike. Verified by mutating the initiator's body: both arms fail, where the previous assertions would have passed. Also narrow a comment in 01413 that claimed every refused command is re-run once the setting is enabled. Nine of the eleven are. MATERIALIZE PROJECTION cannot be, because the projection is dropped earlier so that DELETE FROM is permitted at all, and the _row_exists assignment is only interesting in the refused direction; say so rather than overstating the coverage. The first sentence of the setting description was ungrammatical, and it is visible both in system.settings and in the autogenerated documentation page this change set out to clarify.
Internal second-model review — 5 rounds (4 blockers, 5 majors agreed and fixed; 6 findings refuted)An independent cold review plus a second-model gate ran on every revision, adjudicated against ❌ Blocker — the caller exemption did not survive ❌ Blocker — that dispatch lost one-execution-per-shard routing. ❌ Blocker — SQL user-defined functions were not inlined. The interpreters this path used to ❌ Blocker — the mixed-version window was undisclosed. Measured on a two-node cluster with one ❌ Major — three test oracles were value-blind or unable to observe their own target. The ❌ Major — the setting description contained three inaccuracies, and a PR-body claim was false. 💡 Refuted — 💡 Refuted — naming 💡 Refuted — a proposed cross-version coordination protocol for the mixed-version window. The
|
Pre-PR validation gate
|
|
Workflow [PR], commit [9f9777c] Summary: ✅
AI ReviewSummaryThis PR extends Findings❌ Blockers
💡 Nits
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit 9f9777c.
Changed lines: Changed C/C++ lines covered: 85/86 (98.84%) · Uncovered code |
|
cc @alesapin @tuanpach, could you review this? |
|
@groeneai Some of the following may have been answered indirectly in the PR body, but I'd like to call each out explicitly: Will this have any impact if a cluster is running mixed clickhouse versions during a rolling upgrade - will the old-version clickhouse cluster accept and handle the incoming Are there any likely future consequences for this change in replication mode if row-security policy enforcement is extended to lightweight Will the changes to lightweight What defenses - comments, persistent agent instructions, additional tests, assertions, code structural choke-points to enforce conformance, etc - are in place to prevent this regressing when |
There was a problem hiding this comment.
After an initial somewhat superficial my-human-eyes-and-brain read over the PR, see the comments below.
I also note that the PR code has changes for the DELETE FROM ... path but no apparent changes on the UPDATE path. Is this intentional, or an oversight?
Edit: Per this analysis the UPDATE path already does the right thing but the DELETE path didn't; this PR brings DELETE up to parity with UPDATE.
I'm a little concerned about how it makes changes to inlining and query replication for the DELETE FROM ... path alone, without apparently checking for consistency with other paths like UPDATE and SELECT.
Edit: It looks like that inlining is consistent with how UPDATE works per 99ca3b4 but that change didn't apply the same logic to DELETE. That makes it less concerning, it's fixing an inconsistency not introducing major new behaviour.
| - `UPDATE` whenever it runs as a heavyweight mutation, which is the default | ||
| `alter_update_mode = 'heavy'` and every case the other modes fall back to, `DELETE WHERE`, |
There was a problem hiding this comment.
This passage appears to claim that UPDATE and DELETE ... are blocked by allow_non_metadata_alters = 0, but on lines 5528...5531
Other `ALTER` statements are allowed, including `ADD COLUMN`, `COMMENT COLUMN`,
`MODIFY SETTING`, an `Enum` extension, and `DROP COLUMN` of an `ALIAS` column. The
`DELETE FROM` and `UPDATE` statements are allowed in every mode they support: the setting
governs `ALTER` DDL, not the dedicated delete and update statements.
this text appears to say they are permitted. The verbiage "allowed in every mode they support" is unspecific, and the claim " setting governs ALTER DDL, not the dedicated delete and update statements" appears to directly contradict the prior passage.
So does this block DELETE FROM ... and UPDATE ... or not, and if it can, under what circumstances?
There was a problem hiding this comment.
You are right, and it was ambiguous rather than merely unspecific: the bullet list used the bare word UPDATE for the ALTER TABLE ... UPDATE command, and the paragraph below used it for the UPDATE ... SET statement. Two different statements, one word.
Fixed in 3833eea: every command is now spelled with its full statement form, and the paragraph says explicitly that DELETE FROM ... and UPDATE ... SET ... are different statements which this setting never refuses.
To answer the question directly: it does not block them, in any mode. Under the default lightweight_delete_mode = 'alter_update' a DELETE FROM does synthesize the same ALTER ... UPDATE _row_exists = 0 internally, so the storage sees a mutation and would refuse it; the interpreter that synthesizes it grants the exemption on its own private context, so provenance decides, not statement shape. A user-written ALTER TABLE ... UPDATE \_row_exists` = 0` is still refused, which 01413 pins.
I also removed the confine them with permissions advice I had given you earlier on the issue. Measured: DELETE FROM and ALTER ... DELETE WHERE both check ALTER_DELETE, and revoking it fails both with 497. The privileges cannot separate the two forms, and the description now says so.
| /// Inline the bodies of SQL user-defined functions before the database is filled in, otherwise an | ||
| /// unqualified table inside a body is resolved later, in a context whose current database is not | ||
| /// the database of the deleted-from table. | ||
| if (!UserDefinedSQLFunctionFactory::instance().empty()) | ||
| UserDefinedSQLFunctionVisitor::visit(query_ptr, getContext()); |
There was a problem hiding this comment.
Is this added inlining applied consistently across all query execution paths? It's a significant change that affects the delete path even when allow_non_metadata_alters = 1 so its possible impact needs to be carefully considered.
Are there any user-privilege or access-rights implications to this inlining step being done at this point?
There was a problem hiding this comment.
Update: Per 99ca3b4 it looks like this change just brings DELETE into conformity with other query paths so it should be fine. I don't have permission to resolve my own review thread though, so I can't close this.
There was a problem hiding this comment.
Consistent, yes: InterpreterAlterQuery (:419) and InterpreterUpdateQuery (:93) both already inlined, and this path re-entered one of them, so the expansion was always happening. What changed is only that it now happens here first, in the interpreter that owns the statement. That matters because the clustered branch returns before either of those is reached, so without it the raw statement shipped with the UDF call unexpanded.
You are right that it is unconditional, and I have corrected the PR body: it previously said "behaviour changes only where the setting is 0", which was false for this bullet and for the routing one. Inlining and clustered dispatch change at any value of the setting, including the default.
On access rights: none. The visitor performs no access check of its own and there is no privilege on a SQL UDF to check. Ordering is unchanged in the sense that matters: the expansion precedes checkAccess(AccessType::ALTER_DELETE, table_id) here (:81) exactly as it precedes checkAccess(required_access) in InterpreterUpdateQuery (:93 before :153). The privilege is checked against the deleted-from table, which the expansion does not alter. What the expansion does change is which tables the predicate reads, and those are resolved and access-checked when the mutation's SELECT is planned, not here.
| /// Substitute the database into table functions that use the current database implicitly, e.g. | ||
| /// `merge('tables_regexp')`, before `executeDDLQueryOnCluster` replaces `currentDatabase()` with | ||
| /// the database of the session. The table identifiers are qualified on each host instead. |
There was a problem hiding this comment.
Is there any reason this qualification shouldn't be done unconditionally during the initial statement parse and rewrite pass before node-local execution too? Unless the computational cost is significant, which looks unlikely, this might be a sensible defensive step to to take at the point where the client query is received and any implicit session state is bound to the query itself.
It's probably not justifiable to do that in this PR as it expands the scope of these changes past the necessary minimum footprint, but I'd like to flag it for consideration in future.
There was a problem hiding this comment.
OK, so upon further review this change makes DELETE consistent with how UPDATE works, so it's the logical way to do it for now.
There was a problem hiding this comment.
Agreed on both counts, including that it does not belong here. The cost is negligible: the visitor returns immediately when no SQL UDF exists, which is the guard on this call.
I am not raising a follow-up for it. It has no user-visible consequence I can demonstrate today, so it would be a refactor rather than a fix, and I would rather leave the note here for whoever does canonicalize the parse pass than manufacture a task for it.
| /// The cluster case ships the DELETE itself rather than a rewritten ALTER, so that every host | ||
| /// derives its delete mode and its own storage-check relaxation from its own settings. |
There was a problem hiding this comment.
Is there any difference in the implied session-state that is inherited across a replicated query for an ALTER ... DELETE ... vs a bare DELETE ... that might lead to unexpected changes in how this statement behaves? For example, session/query level settings that might apply to the DELETE when it executes an implied ALTER ... DELETE ... locally but are not currently bound into the replicated DELETE ? Or vice versa?
In other words, can this change in how deletes are replicated cause any surprising changes in behaviour due to side-effects from session state?
Edit to follow-up after some studying and tool-based assessment: this does have a user-visible impact but it makes DELETE more consistent with UPDATE. I'll have an LLM tool post a follow-up with details, but it looks like this mainly needs some emphasis on the corner-case behaviour changes for DELETE in release-notes and maybe a consistency check between update and delete docs to verify claims about clustered execution.
There was a problem hiding this comment.
Posted by an LLM on my behalf.
Summary: Session-state semantics do shift, but in the same two directions UPDATE already shifted (per-host mode selection and origin-pinned UDF meaning), so the concern is real but there's a working precedent — the one gap is docs, which only mention alter_update_mode.
Details
Both master's DELETE … ON CLUSTER → ALTER … UPDATE ON CLUSTER rewrite and this PR's ship-DELETE go through executeDDLQueryOnCluster → DDLLogEntry. DDLLogEntry::setSettingsIfRequired serialises context->getSettingsRef().changes(), i.e. every session-level SET the origin performed, and each worker replays them onto the task context before interpreting. So explicit origin SETs ride along identically in both paths. The concern isn't "which settings survive"; it's "which side reads them, and when".
Where the two paths diverge
-
Mode selection (
lightweight_delete_mode). Master resolves the mode once, on origin (that's what turnsDELETEinto either a lightweightUPDATE _row_exists=0or anALTER UPDATE). Every host receives that already-baked decision. The PR defers the choice to each host. If the origin didSET lightweight_delete_mode=…, it rides along in.changes()and hosts see it, so nothing surprising there. What is new: hosts with heterogeneous profile-level defaults will now legitimately pick different modes on different hosts, whereas master silently forced the origin's default onto all of them. The PR body says this is intentional (each host picks its own storage-check relaxation and its own mode), and it's also exactly the semanticsUPDATEhas had since it started shipping itself instead of ship-ALTER. -
Gates re-checked on hosts.
enable_lightweight_delete,enable_lightweight_update, projection mode,supportsLightweightDelete,supportsDeletewere previously gated only on origin (the shippedALTER UPDATEdoesn't have to satisfy them). On ship-DELETEthey re-fire on every host. The same widening happened forUPDATE: hosts run through the fullInterpreterUpdateQuerygates. In practice these gates read either server settings or engine capability, neither of which is truly "session state". -
lightweight_deletes_sync→mutations_syncmapping. Master doescontext->setSetting("mutations_sync", lightweight_deletes_sync)on a copied context on origin, and the ALTER ships with that synthesised change. The PR defers it: each host does the same mapping locally when it re-entersInterpreterDeleteQueryon the ship-through. Because.changes()still carries the origin's overriddenlightweight_deletes_sync(if any), hosts observe the same value. Symmetric. -
UDF inlining timing. Master's ship-
ALTER … UPDATEnever inlined SQL UDFs at the DELETE layer, so a UDF-defining reference travels as-is and is resolved from whatever UDF registry the host has — which is allow_non_metadata_alters=0 does not block many mutation-triggering ALTERs and its documentation is unclear #115058. The PR inlines unconditionally at the top ofInterpreterDeleteQuery, before shipping. The shipped predicate is now bound to the origin's UDF registry snapshot; hosts with locally-different UDFs are no longer surprising, but the semantic is now "origin defines the UDF meaning", which is a new (and correct) invariant.UPDATEdid the same move in 99ca3b4 (unconditionalUserDefinedSQLFunctionVisitor::visitguarded only by non-empty factory). -
Query-body normalisation / default-database pinning.
substituteDatabaseInTableFunctionsonpredicateandpartitionmirrors whatUPDATEalready does onpredicateandassignmentsand whatALTERdoes oncommand_list. One minor consistency delta:UPDATE's ON CLUSTER branch guards this call byif (resolved_table_id). This PR's DELETE cluster branch does not — it constructsAddDefaultDatabaseVisitor(getContext(), table_id.getDatabaseName())unconditionally. It's safe here because control has already flowed past aDatabaseCatalog::instance().getTable(table_id, …), sotable_idis fully qualified by the time we reach it, but the shape doesn't matchUPDATE.
The concrete "gotcha" list
Two behaviour shifts a user could realistically notice:
- A cluster with heterogeneous defaults now picks per-host mode. A DELETE that used to run as ALTER on every host will now run lightweight on hosts whose default is
lightweight_updateand as ALTER on hosts whose default isalter_update. Origin's session-levelSET lightweight_delete_modestill overrides (via.changes()), so the escape hatch works. This exactly mirrorsUPDATE. - Origin's UDF definitions are pinned into the shipped query. Master had the opposite (buggy) semantic.
UPDATEalready made the same switch. Nothing in the docs currently walks a user through this, though — it should probably be mentioned in the same place we talk aboutalter_update_mode.
The one thing that is not symmetric with UPDATE
UPDATE's ship path is entered unconditionally from InterpreterUpdateQuery — there is no "rewrite to ALTER UPDATE first" branch. The PR's ship-DELETE, by contrast, sits above an inner rewrite-to-ALTER (or rewrite-to-UPDATE) fallback for the local case. A per-host resolution can, on some hosts, still end up producing a locally rewritten ALTER UPDATE — but that inner rewrite is re-executed on the host, on the host's session settings, so it inherits the host's mutations_sync mapping and its own allow_non_metadata_alters relaxation. That's the intended asymmetry.
Bottom line
The change does alter session-state semantics for DELETE ON CLUSTER, in two ways that will be user-visible (per-host mode selection; origin-pinned UDF meaning). Both shifts are already present on the UPDATE side and haven't caused observable trouble there. The one place worth pushing on is documentation: the user-facing note only mentions alter_update_mode, and this PR's DELETE-side counterpart (lightweight_delete_mode) now has the same "each host derives it locally on ON CLUSTER" contract — that should be spelled out, especially given #115058 originated from surprise over exactly this class of divergence.
There was a problem hiding this comment.
There is a difference, and it is the point of the change rather than a side effect.
At base, the initiator rewrote the statement to ALTER ... ON CLUSTER ... UPDATE _row_exists = 0 and shipped that. The DDL entry carries the initiator's settings (DDLTask.cpp:126-128), and each worker re-clamps them against its own profile (:356-365, where SettingsConstraints::checkOrClamp erases a rejected change). So the initiator's delete mode was baked in on the initiator, while the setting travelling with it could be silently dropped on arrival. That is precisely how the exemption broke: an operator who constrains allow_non_metadata_alters to 0 to have it enforced got DELETE FROM ... ON CLUSTER failing 524.
Now the DELETE itself is shipped, so each host derives its delete mode and its own relaxation from its own settings. Settings still travel and are still re-clamped the same way; what no longer travels is a decision the initiator made on the initiator's behalf.
One thing genuinely does change and I have made the PR body say so: with distributed_ddl_entry_format_version = 1 no settings ship at all, which the 10-arm matrix covers as its own case.
| /// A user-written `ALTER TABLE ... UPDATE _row_exists = 0` reaches the storage as an | ||
| /// identical command, so `allow_non_metadata_alters` can only be relaxed here. | ||
| context->setSetting("allow_non_metadata_alters", true); |
There was a problem hiding this comment.
Does the placement of this logic have any impact on a cross-version replication environment where the leader is down-version and the executing local node has the new code?
There was a problem hiding this comment.
Posted by an LLM on my behalf.
There is a real cross‑version gap here, but only on the DELETE ... ON CLUSTER path — same‑node and Replicated‑database ALTER replay are both fine.
Detail: how this differs from UPDATE, and where the cluster path leaks
How this differs from UPDATE
The reason UPDATE never needed this bypass — and the reason lightweight DELETE does — comes down to interpreter routing:
- Lightweight UPDATE (
InterpreterUpdateQuery::execute) never touchesInterpreterAlterQuery. It buildsMutationCommandsand callstable->updateLightweight(commands, getContext())directly, which lands inMergeTreeData::updateLightweightImpl(src/Storages/MergeTree/MergeTreeData.cpp:11916). That path does not consultallow_non_metadata_alters. The setting is only ever read atMergeTreeData::checkAlterIsPossible(line 4973), and the only caller of that isInterpreterAlterQuery::execute(src/Interpreters/InterpreterAlterQuery.cpp:352). - Heavy
ALTER … UPDATEis intentionally gated by the setting; that is the setting's raison d'être. - Ship‑UPDATE mode for the DELETE fallback (PR's first branch) re‑enters
InterpreterUpdateQuery, so it inherits UPDATE's setting‑free path — no bypass needed. - Ship‑ALTER‑UPDATE mode (the block under discussion) is the only path that deliberately routes back through
InterpreterAlterQuery, so it is the only path that ever hits the gate. Hence the bypass exists only here, and there is no analogous gap on the UPDATE side to plug.
The comment's assertion — "the setting can only be relaxed here" — is accurate specifically because DELETE's ship‑ALTER fallback re‑enters ALTER, whereas UPDATE never does.
The DELETE ... ON CLUSTER cross‑version gap
Placement of the flip is safe in every topology except DELETE ... ON CLUSTER, and that's the one this comment is really probing.
- Local ReplicatedMergeTree. Coordinator (up‑version) writes the mutation entry to ZK; peers replay it at the MergeTree mutation layer, which never calls
checkAlterIsPossible. Down‑version peers are unaffected. No gap. - Replicated database enqueuing the synthesized
ALTER ... UPDATE _row_exists = 0.DDLLogEntry::setSettingsIfRequired(src/Interpreters/DDLTask.cpp:111) snapshotscontext->getSettingsRef().changes()into the ZK entry, so theallow_non_metadata_alters=trueoverride rides along and is applied to the task context on every peer. Peers re‑enterInterpreterAlterQuerywith the bypass in place, at any version that knows the setting name (which is every supported version). No gap. DELETE ... ON CLUSTER. This is where placement bites. The PR's cluster branch (earlier inInterpreterDeleteQuery::execute, ~lines 161–178 on the PR branch) ships rawDELETE ... ON CLUSTERviaexecuteDDLQueryOnClusterand returns before the context copy that setsallow_non_metadata_altersis ever constructed. Peers therefore receive a plainDELETEwith no such setting change in the DDL entry, and each peer re‑enters its ownInterpreterDeleteQueryfrom scratch. A down‑version peer runs the old code, never sets the bypass, and fails with the exactALTER_OF_COLUMN_IS_FORBIDDENerror the PR is meant to eliminate. The fix therefore does not reach mixed‑version clusters until every host is upgraded.
Contrast this with today's master and with UPDATE, both of which rewrite ship‑DELETE / ship‑UPDATE to the resolved sub‑query on the origin before calling executeDDLQueryOnCluster. If the PR did the same — rewrite to ALTER ... UPDATE _row_exists = 0 ON CLUSTER on the origin and let setSettingsIfRequired carry allow_non_metadata_alters=true — the setting would ride the ZK entry and the fix would apply to every peer regardless of version. That symmetry with the UPDATE path is also the only version‑independent way to close the gap; trying to attach the bypass to the shipped DELETE context only helps peers that are new enough to honour a bypass they don't otherwise need.
There was a problem hiding this comment.
Yes, and it is disclosed in the PR body because I could not design it away.
Routing is not serialized: DDLLogEntry::toString writes no routing field, and each worker recomputes execute_on_single_replica from its own code (DDLWorker.cpp:755). So mid-upgrade an old worker runs the delete locally and pushes no shard marker (that happens only inside the single-replica path, :869/:953), while a new worker finds is_executed_path absent (:927) and executes as well.
I measured the transient on a genuinely mixed two-node cluster, both initiator directions, with each node running a different binary: two identical mutation entries, is_done = 1, parts_to_do = 0, no failure reason, convergent rows. Duplicated work that converges, not divergence.
I deliberately did not add a coordination protocol. The two closest precedents for widening this same list shipped with no version gate and no mixed-version test (f1e1cff27235b97 for CreateIndex/DropIndex, de6f6127074d063 for settings and comment alters), so a bespoke handshake here would be new machinery for a transient that resolves itself. If you would rather have the gate, say so and I will add it.
|
Posted by an LLM (Claude Opus 4.7) on behalf of @ringerc after reviewing this PR against the linked issue and an earlier proof of concept; the summary flags the The LLM questions the PR's claim about the narrow use of Findings on this PR1. The "closed carrier" claim is inaccurate. The pre-PR validation gate states:
A grep of
The guard itself is at the storage layer ( 2. The added UDF inlining is not covered on the single-node path. To be explicit: gating the inlining on the setting would be worse, not better. The whole point of the Related: 3. The setting docstring reads self-contradictorily. Already flagged inline on 4. 5. 6. Stateless test lever pins one direction only. 7. Rolling upgrade transient. The PR body already discloses that on a mixed old/new cluster both workers can complete the same 8. Regression-prevention comment. None of these block the core fix, which reads correctly: |
|
Follow-up posted by an LLM (Claude Opus 4.7) on behalf of @ringerc. Short version: Why this PR doesn't touch the UPDATE path — long formGrepping the current tree confirms the UPDATE side already has the pattern this PR retrofits onto DELETE:
That is what the PR body means by "as Where the guard actually catches UPDATE. Three surfaces:
Why DELETE needed extra plumbing but UPDATE didn't. The asymmetry is one shape only:
Where the PR could still leave something on the table on the UPDATE side:
|
…E inlining locally Review of ClickHouse#115287 pointed out that the description used the bare words UPDATE and DELETE WHERE for the ALTER commands and again for the dedicated UPDATE ... SET and DELETE FROM statements, so the bullet list and the paragraph below it read as contradicting each other. Every command is now spelled with its full statement form, MATERIALIZE TTL is marked as unconditional next to the conditional MODIFY TTL, and the paragraph states what GRANT and REVOKE of ALTER UPDATE and ALTER DELETE can and cannot separate: measured, both privileges cover the dedicated statement and the ALTER command together, so they cannot distinguish the two forms. 01413 pinned alter_update_mode to heavy and lightweight only, so the rule that a lightweight rewrite never reaches the mutation path was unpinned for lightweight_force; it now has an arm. The inlining of SQL user-defined functions added to InterpreterDeleteQuery was covered only through the ON CLUSTER integration test. 04812 now runs the same predicate shapes through a local DELETE FROM, which pins that the local path keeps resolving an unqualified table in the body against the deleted-from table's database.
The second added DELETE arm deleted a row the first one had already removed, so it was satisfied by the previous statement rather than by its own predicate. Each arm now targets a distinct freshly inserted row, and the two candidate resolutions of the body select different rows, so a wrong resolution changes the output: verified by mutating the body, which reddens the reference. The comment on hasNonEmptyMutationCommands claimed a command answering it always reaches the guard. A lightweight ALTER UPDATE is intercepted before runCommandSegments and never reaches it, so the comment is limited to the commands that do take the heavyweight path.
|
Thanks. Two of these were real defects in my own artifacts, fixed in 3833eea; the five inline threads are answered individually.
Finding 1. The count is wrong, and here is what it means. Five of your six sites carry only commands Finding 5. Finding 6. First half right and fixed: Finding 2, and I want to be precise about what it proves. 04812 now runs the same shapes through a local 3, 4, 8 fixed (full statement forms throughout; Row security: nothing here constrains it. The guard is admission-only and reads one boolean; it does not touch predicates or which rows a mutation selects. If anything it helps, since a clustered Defenses against a future Rolling upgrade is answered inline with the mixed-version measurement. And thanks for the categorisation answer on the issue, particularly the migrator-tool reasoning; |
Review of ClickHouse#115287 pointed out that lightweight_delete_mode does not say what happens under ON CLUSTER, which is the class of divergence issue ClickHouse#115058 was reported from. Each host derives the mode from its own settings, so hosts with different profile defaults can run the delete in different modes; a session-level change travels with the distributed DDL entry and overrides that, except on a host that constrains the setting, which clamps the value back.
Review of ClickHouse#115287 noted that the existing coverage exercises a ReplicatedMergeTree table in an ordinary database, which is not the same case as a Replicated database, while the PR body claimed the latter was covered by the same predicate. The arm this adds is the reachable form of that case. DELETE FROM ... ON CLUSTER cannot be used against a Replicated database at all: the host-side entry is a non-initial query, so DatabaseReplicated::tryEnqueueReplicatedDDL rejects it with INCORRECT_QUERY, both with and without ignore_on_cluster_for_replicated_database, and both before and after this PR. A plain DELETE reaches the same routing instead, because the database replicates it whenever it has more than one shard. Measured over the four-host shape: before the DDLWorker change every replica of a shard mutates the shared table, so system.mutations holds 2 entries per host, and after it holds 1.
The paragraph said every host derives the mode, which overstates it: DDLWorker leader-routes a DELETE when the storage supports replication, so a replicated shard runs it on one replica and that replica's settings are the ones that decide.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes7 object files changed (+35.37 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units10 translation units recompiled, 68 s compile time in total, 10 of them have a recent master baseline. |
If there's a good justification for not having the local test as it follows a demonstrable common path, that's ok; just ensure that comments clearly call this out so future reviews don't wonder why there's no test cover for the local-only path. Otherwise fine. |
|
@alexey-milovidov @alesapin maybe I need your help because |
The two DELETE FROM rows read the same on a binary without the routing change, because the local path re-enters the UPDATE or the ALTER interpreter and both of those already inline SQL function bodies before the database is filled in. Record that at the arms so the absent local-only discrimination is not read as a gap. Asked for by @ringerc in review.
|
Recorded at the arms in The comment states the invariant rather than the history: a local Measured rather than argued, on two debug binaries: base |
|
|
||
| /// The cluster case ships the DELETE itself rather than a rewritten ALTER, so that every host | ||
| /// derives its delete mode and its own storage-check relaxation from its own settings. | ||
| if (!delete_query.cluster.empty()) |
There was a problem hiding this comment.
This ON CLUSTER dispatch now exists only on the supportsLightweightDelete() path. For engines that take the earlier supportsDelete() branch instead (KeeperMap, EmbeddedRocksDB, StorageObjectStorage/Iceberg, system.wasm_modules, and aliases of them), DELETE ... ON CLUSTER still falls through to the local table->mutate() call and silently ignores the cluster clause. That turns a cluster-scoped delete into a single-node delete with no error.
Can we move the !delete_query.cluster.empty() handling above the supportsDelete() / supportsLightweightDelete() split, or explicitly reject ON CLUSTER in the direct-delete branch until that path is wired too?
There was a problem hiding this comment.
The asymmetry is real, but it predates this branch rather than being introduced by it. On master at 2ae8a25a the supportsDelete branch reads delete_query.cluster nowhere, and executeDDLQueryOnCluster is not included in that translation unit at all: the only two reads of the clause are the UPDATE and ALTER text templates, and both sit inside the supportsLightweightDelete branch. So a DELETE FROM ... ON CLUSTER against KeeperMap or EmbeddedRocksDB already falls through to the local mutate call today, exactly as it does here.
What this diff changes is how the lightweight branch dispatches: it ships the DELETE itself instead of a rewritten ALTER. It adds nothing to the direct-delete branch and removes nothing from it, so the gap is unchanged in kind.
I am not folding the rejection into this PR. Making a statement that succeeds today throw is backward incompatible, and it would widen a PR that @ PedroTadim has already asked an area expert to review. A reviewer is welcome to decide otherwise.
Master removed the window view storage in ClickHouse#114747, so the branch's only conflict is the modify/delete on StorageWindowView.cpp. Accepted the deletion. The arm it carried relaxed allow_non_metadata_alters around the internal cleanup ALTER that StorageWindowView issued for windows past the watermark. That synthesizer no longer exists, so the relaxation has no caller and is dropped rather than relocated. The other internal synthesizers the branch covers are unaffected. Co-Authored-By: Claude Opus 5 <[email protected]>
Build (arm_tidy) failed with readability-duplicate-include on InterpreterDeleteQuery.cpp:12 and :13, which dropped every downstream job, including all four Bugfix validation jobs, so Finish Workflow then failed its new_tests_check hook for having no validation result. Neither side carried a duplicate on its own. This branch added the two UserDefined includes to the sorted block; master's legacy-toTime change later added the same two to the leading block. The merge took both. Removed the pair this branch added and kept master's placement, so the file's include layout now matches master exactly. Duplicate includes compile fine, which is why a plain build of the translation unit did not catch it. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Master had moved past the merge base by then, so the branch was conflicting on the file One gap I did not close: nothing pins the initiator-side database substitution for the dedicated clustered |
`DELETE FROM ... ON CLUSTER` is queued as itself rather than as a rewritten `UPDATE` or `ALTER`, so it substitutes the database into the table functions of its predicate on its own, before `executeDDLQueryOnCluster` replaces `currentDatabase()` with the database of the session. Nothing pinned that substitution: every clustered `DELETE FROM` covered so far uses either a literal predicate or a SQL user-defined function, and both of those shapes return the same rows whether the substitution runs or not. Measured with the substitution removed, the new arm deletes `id = 3`, the row that the source table of the session database selects, instead of `id = 2`. The twelve pre-existing arms of this test and both predicate shapes above stay green in that build, so none of them can see the difference. The read-back is deterministic: the statement waits for the host through `distributed_ddl_output_mode`, and `lightweight_deletes_sync = 2` makes the host wait for its own mutation. 13 runs pass, 5 of them concurrent with each other. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Fixing PR for the That crash is pre-existing on master and not caused by this PR. The unguarded dereference is at |
CI finish ledger - b49f3f3Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose
None of the four is attributable to this diff, which only tightens Reports:
Session id: cron:our-pr-ci-monitor:20260830-190000 |
|
Fixing PR for the My ledger row above stops one level short of the leaf. The destructor's join really has no timeout, but what it waits for is an S3 retry loop that does have a cancellation hook.
Since
|
| - `lightweight_update` - run lightweight update if possible, run `ALTER UPDATE` otherwise. | ||
| - `lightweight_update_force` - run lightweight update if possible, throw otherwise. | ||
|
|
||
| For `DELETE FROM ... ON CLUSTER`, each executing host derives the mode from its own settings, so |
There was a problem hiding this comment.
The new lightweight_delete_mode text makes DELETE FROM ... ON CLUSTER part of the public contract, but the source-level DELETE statement docs in src/Parsers/ParserDeleteQuery.cpp still describe every DELETE as a rewrite to ALTER TABLE ... UPDATE controlled by lightweight_deletes_sync.
After this branch, the clustered path is queued as DELETE itself and each executing host can re-resolve lightweight_delete_mode, so the setting docs and the statement docs will disagree in the release. Can you update the structured DELETE docs in ParserDeleteQuery.cpp in the same PR?
There was a problem hiding this comment.
Checked both doc sites at the current head before answering.
ON CLUSTER is not new to the statement docs: ParserDeleteQuery.cpp:123 and :211 already document DELETE FROM [db.]table [ON CLUSTER cluster] .... This branch changes where the delete mode is resolved, not that surface.
Nothing in that file ties the ALTER TABLE ... UPDATE rewrite to lightweight_deletes_sync. Line 141 attributes only synchronicity to it, and that still holds: the queue entry drops ON CLUSTER (ASTDeleteQuery.h:21, executeDDLQueryOnCluster.cpp:249), so each host runs the local path and copies lightweight_deletes_sync into mutations_sync at InterpreterDeleteQuery.cpp:278.
The imprecise sentence is :194-196, "DELETE queries are transformed to ALTER TABLE ... UPDATE". It omits lightweight_delete_mode = lightweight_update / lightweight_update_force, which run a lightweight update instead. That predates this branch: lightweight_delete_mode is declared on master at Settings.cpp:5029, and the sibling statement docs already state the exception at ParserUpdateQuery.cpp:169. Revert this branch and :194 still needs the same edit, so it is not a contradiction this PR introduces.
I am leaving it out of this PR: it is a standalone master docs fix that also regenerates the autogenerated docs/reference/statements/delete.mdx. The behaviour this branch does add, per-host mode resolution for a clustered delete, is documented on the setting itself at Settings.cpp:5037.
|
Looks like this is still pending maintainer eyes. I'll keep an eye on it. |
|
@alexey-milovidov one last call to review |
| /// Every command that passes `hasNonEmptyMutationCommands` rewrites parts on disk. | ||
| /// Callers that synthesize an ALTER on behalf of a lightweight write relax the setting | ||
| /// on their own context copy, so provenance is decided there, not by command shape. | ||
| if (!settings[Setting::allow_non_metadata_alters] && commands.hasNonEmptyMutationCommands()) |
There was a problem hiding this comment.
allow_non_metadata_alters = 0 no longer fails this class of ALTER atomically. runCommandSegments applies earlier AlterCommands segments before it reaches the later MutationCommands segment and calls checkMutationIsPossible (InterpreterAlterQuery.cpp:345-375), so a query like ALTER TABLE t ADD COLUMN x UInt8, DELETE WHERE 0 now commits the ADD COLUMN and only then throws ALTER_OF_COLUMN_IS_FORBIDDEN.
That is a user-visible regression from “the statement is refused” to “the statement partially succeeds and then raises”, which is especially risky for a protective setting like this one. Can we reject non-empty mutation segments up front, before any segment runs, instead of only from this per-segment hook?
There was a problem hiding this comment.
Measured before answering, on this head (9f9777cf) and on a master build from today (fb2a5923, without this PR).
The ADD COLUMN does survive. It also survives on master, so this PR does not introduce it, and there is no "the statement is refused" baseline to regress from:
| binary | ALTER TABLE t ADD COLUMN x UInt8, DELETE WHERE 0 with allow_non_metadata_alters = 0 |
|---|---|
master fb2a5923 |
rc=0, full success: x added and the DELETE WHERE 0 mutation created and completed |
| this head | Code: 524; x added; 0 mutations |
The only change for that statement is that the data-rewriting mutation is refused instead of executed, so strictly less runs than before and nothing previously refused is now accepted.
Per-segment refusal under this setting is pre-existing as well. On the same master build:
SET allow_non_metadata_alters = 0;
ALTER TABLE t ADD COLUMN x2 UInt8, DELETE WHERE 0, DROP COLUMN v;
-- Code: 524 ... '(DROP COLUMN v)' ... (ALTER_OF_COLUMN_IS_FORBIDDEN)
-- x2 committed, and the intervening DELETE WHERE 0 mutation ran to completion
runCommandSegments validates each segment when it reaches it, and this PR changes neither that loop nor segment ordering.
On moving the check up front beside validateMutationsAllowed: that helper is engine-blind because disable_insertion_and_mutation is a server setting. This one is not. checkMutationIsPossible is a per-storage virtual and only MergeTreeData reads the setting; the Join, KeeperMap, EmbeddedRocksDB, Redis, object-storage/Iceberg, Memory and system.wasm_modules overrides all take const Settings & unused. Measured on both binaries: ALTER TABLE <Memory> DELETE WHERE k = 2 under allow_non_metadata_alters = 0 deletes the row and is refused by neither. An up-front reject in the interpreter would start refusing all of those, which is wider than the reported bug and wider than what the setting documents.
So I am keeping the check in the predicate that already decides whether the mutation runs. Atomicity of a multi-segment ALTER is a separate, pre-existing property.
There was a problem hiding this comment.
TL;DR: the issue identified is real, but orthorgonal to this PR and not a new regression introduced by it.
@groeneai Look for existing github tickets for the problem. If none are found, raise a new github issue for it. Link to #115287 (comment) for context.
There was a problem hiding this comment.
An existing ticket covers it, so I have not raised a new one: #103653 (open since 2026-04-28, comp-ddl + comp-mutations, assigned).
Same defect, different trigger. Its root cause section names this exact seam: runCommandSegments commits each segment as it reaches it, so an earlier segment is already committed when a later one is rejected, and nothing rolls it back. Verified still true on master (fb2a5923): table->alter commits at InterpreterAlterQuery.cpp:367, the next segment's check runs at :374, the loop has no catch, and validateSegmentsCombination (:225) pre-validates nothing across segments beyond partition/execute mixing. Its "Open risks" section already flags "other combinations of DDL + DML across segments", which is what ADD COLUMN x UInt8, DELETE WHERE 0 is.
Its repro trips the seam with RENAME COLUMN c0 TO c1, UPDATE c0 = 1 WHERE true, where the RENAME sticks after the statement fails with NO_SUCH_COLUMN_IN_TABLE, rather than with the setting check. The mechanism, the code location and the suggested fix (cross-segment validation before any commit) are the same, so I read it as covered rather than filing a duplicate.
Agreed on your reading that it is orthogonal to this PR, so I am not touching the diff here.
|
@groeneai Rebase this and rebuild it against current master. |
|
The tip I did the rebuild half locally instead of restarting CI:
I have not pushed that merge, because it would restart a CI run that finished green on the current head, and the last three refreshes of this branch were the maintainer's own merges rather than mine. If you or a reviewer want the branch refreshed here, say so and I will push a plain non-force master merge (never a rebase). |
|
@alexey-milovidov @PedroTadim Anything I can do to help progress this? |
Closes: #115058
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
allow_non_metadata_alters = 0now also rejects theALTERcommands that reach aMergeTreetable as explicit mutations:UPDATE,DELETE WHERE, the fiveMATERIALIZEforms,APPLY DELETED MASK,APPLY PATCHESandREWRITE PARTS. Previously the check only saw the commands represented by the schema-alter path, so these rewrote parts anyway.DELETE FROMandUPDATEstay permitted, includingON CLUSTER. The setting description now lists what is refused, and that the check isMergeTree-only.Description
The setting was only read in
MergeTreeData::checkAlterIsPossible. The commands listed above go into aMutationCommandssegment, which callscheckMutationIsPossible, whoseSettingsparameterMergeTreeDatadeclared unused. The fix names it and rejects whenhasNonEmptyMutationCommands()holds, the predicate that already decides whether the mutation runs, so guard and execution cannot drift.Plain
DELETE FROMneeded care: under the defaultlightweight_delete_modeit synthesizesALTER TABLE ... UPDATE _row_exists = 0, which the storage cannot tell from the user-written form. Exempting by shape would reopen the hole, so the synthesizing interpreter grants it on a private context.A setting cannot carry that provenance across nodes: the worker re-clamps shipped settings against its own profile. So
DELETE FROM ... ON CLUSTERnow dispatches theDELETEitself, asInterpreterUpdateQuerydoes. Two consequences:DDLWorkernow leader-routesASTDeleteQuery, so a replicated shard runs it once, not once per replica. This also covers a multi-shardReplicateddatabase, which is reached by a plainDELETErather than byON CLUSTER: it replicates theDELETEat database level, andON CLUSTERagainst it is rejected as a non-initial query both before and after this PR. Mid-upgrade an old and a new worker can both execute one entry, which duplicates the mutation and converges; the two closest precedents also shipped ungated.InterpreterDeleteQuerynow inlines SQL user-defined functions, as the interpreters it used to re-enter did. That store is not replicated by default, so an unexpanded body either failed withUNKNOWN_FUNCTIONon the other hosts or, if defined differently there, silently deleted different rows there.Refusals happen only where the setting is 0, but the two bullets above apply at any value of it, including the default. @PedroTadim, the compatibility question is open if you prefer the docs half.
Validation,
allow_non_metadata_alters = 0on a debug buildThree binaries: base, the guard without the caller exemption, and the fix.
ALTER ... UPDATE _row_exists = 0, local andON CLUSTERDELETE FROM(default mode)DELETE FROM ... ON CLUSTER, profile constrains the setting to 0DELETE FROM(lightweight_updatemode)UPDATE ... SETDROP COLUMNof anALIAS,ADD COLUMN,COMMENT COLUMN,MODIFY SETTING= 1524 is
ALTER_OF_COLUMN_IS_FORBIDDEN, the code the existing alter-path guard already throws.DELETE FROMis the only cell where the middle column differs from the fix, so the relaxationis exactly one statement wide.
01413_allow_non_metadata_altersis extended with these cases and fails without the fix; eachnew expected-error line was justified against the base binary first, where all of them succeed.
The clustered cases need a settings profile, which a stateless test cannot set, so they live in
test_allow_non_metadata_alters_on_cluster(11 arms). Two assert a single mutation entry pershard, one for a
ReplicatedMergeTreetable reached byON CLUSTER, one for a multi-shardReplicateddatabase reached by a plainDELETE; both fail on the base binary with 2 entries.lightweight_deletes_syncis 2 and the DDL output mode isTHROW, so that read happens afterevery host finished, with no polling or sleep. Two define a function on
one host only, and differently on each host: without the inlining they fail with
UNKNOWN_FUNCTIONand with divergent surviving keys respectively.Workflow [PR]
Sync PR [sync-upstream/pr/115287]
Version info
26.10.1.487-master(included in26.10and later)