Skip to content

Let a replica finish starting up when a metadata ALTER was interrupted - #119237

Open
groeneai wants to merge 4 commits into
ClickHouse:masterfrom
groeneai:fix-115549-adopt-committed-metadata-on-interrupted-alter
Open

groeneai wants to merge 4 commits into
ClickHouse:masterfrom
groeneai:fix-115549-adopt-committed-metadata-on-interrupted-alter

Conversation

@groeneai

@groeneai groeneai commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed a ReplicatedMergeTree replica staying readonly across every restart with Code: 122, INCOMPATIBLE_COLUMNS (or Code: 342, METADATA_MISMATCH) when the server was killed between the two halves of a metadata ALTER. Such a replica now starts up by applying the metadata it already committed to Keeper, and its replication queue finishes writing the local metadata file. Tables in a Replicated database are not covered by this change.

Description

Requested by @ zlareb1 in #115549 (comment).

What breaks. executeMetadataAlter commits a metadata ALTER in two steps: a Keeper multi on
/replicas/<r>/{columns,metadata,metadata_version}, then the local metadata file. A SIGKILL between them
leaves the znodes ahead of the file. On restart the attach thread compares the structure with those
znodes, throws, and sets initialization_done, so nothing retries; the throw precedes the queue load, so
the queued ALTER_METADATA never runs.

The change. Before that check, adopt this replica's committed Keeper metadata in memory when a queued
ALTER_METADATA entry accounts for it byte-for-byte: same alter_version as the metadata_version
znode, columns_str/metadata_str equal to the columns/metadata znodes, which excludes a lagging
replica. Nothing is written; the unmodified executeMetadataAlter persists the file when the queue
replays the entry. Without a match the replica refuses as today.

Weigh this. That witness is inexact both ways. removeProcessedEntry's delete is a tryRemove whose
failure is only logged, so a successfully executed ALTER can retain its entry: a locally diverged file
is then overwritten by the queue, where today the replica stays readonly. And if something else consumes
the entry before this replica replays it (another process holding is_active, manual deletion), startup
succeeds on the adopted metadata but the file stays stale, so the next restart refuses until a later
ALTER.

Scope. This recovers the crash-window variant: a SIGKILL or OOM-kill between the Keeper multi and
the local rename. It does not recover the rename-rollback variant from the issue's original reproducer:
there the entry is already gone, so nothing authorises adoption and the replica still refuses. #111405
prevents that route; a replica already bricked that way needs an owner-level option from #26327, so I am
not closing #115549 here. Replicated databases are excluded: replaying the entry there needs the DDL
transaction executeMetadataAlter builds, so that window stays open there.

Validation detail

tests/integration/test_replicated_alter_metadata_interrupted_commit/ drives the state through a new
PAUSEABLE_ONCE failpoint placed after the Keeper multi, so it reproduces the reporter's state, not an
approximation. No sleeps: SYSTEM ENABLE FAILPOINT, ALTER ... SETTINGS alter_sync = 0,
SYSTEM WAIT FAILPOINT ... PAUSE, then a SIGKILL restart. Each arm first asserts the torn state exists
(metadata_version advanced, queue child present, altered field not visible locally) so it cannot
degrade into a plain-restart test.

  • test_columns_delta_recovers - the Code: 122 report. Also asserts the queue drains to 0 (so
    executeMetadataAlter, not attach, persisted the file) and that a second, plain restart starts
    clean - what fails if adoption left the file stale.
  • test_new_column_in_sorting_key_recovers - ADD COLUMN z, MODIFY ORDER BY (x, y, -z), where the Keeper
    metadata references a column the local table does not have yet.
  • test_projections_delta_recovers - the Code: 342 report (DROP PROJECTION), another throw site.
  • Four arms assert the old refusal still happens: no_pending_entry (queue child deleted), plus
    entry_{version,payload,metadata}_mismatch, each rewriting one committed znode (metadata_version,
    columns, metadata) so exactly one of the predicate's three comparisons can refuse; disabling one
    reddens only its arm.

Without the fix, arm 1 fails on is_readonly with Code: 122 ... Table columns structure in ZooKeeper is different from local table structure.

The in-memory half of setTableStructure is now shared; guarded by
00754_alter_modify_order_by_replicated_zookeeper_long, 00062_replicated_merge_tree_alter_zookeeper_long,
test_replicated_database, test_alter_settings_or_comment_on_cluster, test_restore_replica,
test_consistent_parts_after_clone_replica, test_fix_metadata_version,
test_restore_replica_metadata_version - all green.


Workflow [PR]
Sync PR [sync-upstream/pr/119237]

A metadata ALTER commits to Keeper and to the local metadata file in two
separate steps: executeMetadataAlter first sets /replicas/<r>/{columns,
metadata,metadata_version} in one multi, and only then writes the local
metadata file. Nothing between the two touches the filesystem, so a SIGKILL,
an OOM kill or a power cut in that window leaves this replica's znodes ahead
of its own metadata file on an otherwise intact filesystem.

On the next start, ReplicatedMergeTreeAttachThread::runImpl runs the
structure check against those advanced znodes with strict_check = true and
throws INCOMPATIBLE_COLUMNS (or METADATA_MISMATCH for projections and the
other mutable fields). run then sets initialization_done, so no retry is
ever scheduled and the replica is readonly across every restart. The throw is
upstream of the queue load in tryStartup, so the ALTER_METADATA entry that
would write the metadata file can never execute, and part reconciliation never
runs either. force_restore_data does not help: it is only consulted by
checkParts, after the throw.

Before the structure check, adopt the replica's own committed Keeper metadata
in memory when an unexecuted ALTER_METADATA entry in its own queue accounts
for it: the entry's alter_version equals the metadata_version znode and its
columns_str/metadata_str are byte-equal to the columns/metadata znodes the
same multi wrote. That way we only ever adopt bytes Keeper already holds for
this replica, a merely lagging replica is excluded, and the entry is a durably
queued instruction to make the local file match. Nothing is written here: the
metadata file is persisted afterwards by the unmodified executeMetadataAlter
once the queue replays the entry, so a kill in the gap simply reproduces the
same recoverable state. When no such entry exists, behaviour is unchanged and
the check throws exactly as before.

The queue is only scanned once a consistency fast path fails, and that fast
path compares columns before metadata. The order matters both ways: the Keeper
metadata can only be parsed against the columns from the same source, and
comparing metadata structurally is safe precisely because it is unreachable
when the columns differ. It also keeps queue parsing out of the attach
thread's non-retrying failure domain for every state that is still
recoverable, and leaves a healthy replica on today's path.

Adoption is in memory only because DatabaseOrdinary::alterTable calls
waitDatabaseStarted, and the database startup job waits on every table
startup job, which is what the attach thread's first try runs inside; the
existing fixReplicaMetadataVersionIfNeeded adjusts metadata in memory for
the same reason. metadata_version is deliberately left untouched:
cloneMetadataIfNeeded returns early when the in-memory version already
equals the source's, so publishing it here would suppress the dummy
ALTER_METADATA entry a lost replica relies on and leave the metadata file
behind with nothing left to update it.

The in-memory half of setTableStructure is extracted into
applyMetadataInMemory so both paths share it, and serialization hints are
reset the same way executeMetadataAlter does, since setNotReadonly
precedes queue activation.

Replicated database tables are out of scope: there the three sets ride inside
a ZooKeeperMetadataTransaction that executeMetadataAlter needs in order to
replay the entry, so adopting one would have to reconstruct that transaction.
That engine keeps the window - DatabaseAtomic::commitAlterTable commits the
transaction and only then renames the local file, with its own NOTE saying the
replica is lost if the server crashes in between - and recovering it there is a
separate change.

The new integration module drives the real torn state through a PAUSEABLE_ONCE
failpoint after the multi, and covers both reported signatures, the case where
the Keeper metadata names a column the local file does not have yet, and four
arms that must still refuse: no entry accounting for the divergence, and an
entry disagreeing with each of the three znodes the predicate compares -
alter_version against metadata_version, columns_str against columns,
metadata_str against metadata. The last three leave the queue intact, so each
pins one authorisation gate: with that gate alone disabled its arm fails while
the other two still pass.

This recovers the crash-window variant. It does not recover the one in which
the local rename was rolled back after executeMetadataAlter had returned and
removeProcessedEntry had already deleted the queue entry: no witness of the
committed metadata survives there, so nothing authorises adoption and the
replica still refuses. ClickHouse#115549 therefore stays open.

Related: ClickHouse#115549
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (independent cold review + adversarial gate, adjudicated)

Before publishing I ran an independent cold review of the resulting code on every revision plus a separate
adversarial gate pass, then adjudicated each finding against the recorded evidence. Four rounds, 21
findings. Verdicts below.

Blockers (fixed before this PR was published)

  • This PR must not auto-close ReplicatedMergeTree replica becomes permanently readonly (Code 122) when power loss reverts an applied ALTER's local metadata commit; force_restore_data / RESTART REPLICA / RESTORE REPLICA all fail to recover #115549. The issue's original deterministic reproducer is the
    rename-rollback variant: there executeMetadataAlter has already returned, removeProcessedEntry
    has already deleted the queue znode, and nothing survives to authorise adoption, so that replica still
    refuses (test_no_pending_entry_still_refuses asserts it). Recovering it would mean adopting Keeper
    metadata in a state where torn-ness is undecidable at attach, because the local metadata_version is
    never persisted, which would also overwrite a hand-edited .sql. That is the owner-level fork in
    If server killed in a moment after table metadata was changed in ZooKeeper but before it was changed locally (by ALTER MODIFY COLUMN) query, it may refuse to start. #26327, not something to decide here. Fixed by narrowing the published contract: Related: instead of
    Closes:, and a Scope paragraph that names the variant this recovers and the variant it does not.
  • The stated reason for excluding Replicated databases was wrong. An earlier revision of this
    description claimed that engine recovers the same torn state through its own digest mismatch. It does
    not: DatabaseAtomic::commitAlterTable commits the DDL transaction and only then renames the local
    metadata file, with an in-tree NOTE: replica will be lost if server crashes before the following rename, and DatabaseReplicated::recoverLostReplica skips an existing table on a UUID match, leaving
    metadata differences to "table replication level", which is the attach path that refuses. The exclusion
    stays, because replaying the entry there needs the transaction executeMetadataAlter builds, but the
    description and the code comment now say that instead of claiming a recovery that does not happen.

Blocker raised, disagreed with evidence, and disclosed

  • The queue witness can be consumed before this replica replays it, leaving startup successful with a
    stale metadata file. Conceded, and now stated in the Weigh this paragraph rather than left implicit.
    I am not fencing it. With one live server the only path that removes this replica's own queue children
    is cloneReplicaIfNeeded, and that path is covered by construction: adoption deliberately leaves
    metadata_version alone, so cloneMetadataIfNeeded does not take its equal-version early return and
    recreates the entry that persists the file. What remains needs two live processes holding is_active,
    the state activateReplica exists to refuse, or a manual znode deletion; in both, master leaves the
    same replica readonly on this boot anyway, no part is written under a stale version, and any later
    ALTER re-satisfies the predicate and persists the file. Fencing adoption behind ownership is not
    possible in this order: the structure check that must not be reached un-adopted runs before ownership is
    acquired, in an attach-thread failure domain that never retries. Refusing startup when the witness has
    vanished would instead keep a replica readonly whose in-memory metadata is byte-equal to Keeper's, which
    is the outage this PR removes.

Majors (fixed before this PR was published)

  • The authorization predicate had no shipped guard. Every positive arm reached the torn state with an
    exactly matching entry and the only negative arm deleted every entry, so none of
    alter_version == metadata_version znode, columns_str == /columns, metadata_str == /metadata was
    exercised in its refusing direction: weakening the predicate to "any queued ALTER_METADATA" would have
    left the suite green. Added one arm per comparison, each keeping the queue intact and breaking exactly
    one committed input, and each shown to fail with only its own comparison disabled while the other arms
    stay green.
  • The sorting-key arm could leave its queue entry pending, and the failpoint is process-global and
    one-shot, so a still-pending entry could consume the one-shot the next arm enables. Fixed by giving that
    arm the same queue-drain wait the other two recovering arms had, with the cross-arm invariant written
    down next to it.

Noted, not blocking

  • On the healthy path the new function reads /replicas/<r>/columns and /replicas/<r>/metadata and
    parses the metadata, and checkTableStructure then reads and parses the same two znodes again: 2 extra
    Keeper reads plus one metadata AST parse per replicated table per start. Sub-second even for a very
    large server, and the cheap remedy (running the non-strict check first and adopting only on failure)
    reorders the columns-before-metadata comparison that makes parsing the Keeper metadata safe at all.
    Happy to do it if you would rather have it.
  • The Replicated-database early return is silent. A log line there would fire on every attach of every
    table in such a database, so it would be noise on healthy tables; say the word and I will add it.
  • checkTableStructureAttempt parses the Keeper metadata before reading the Keeper columns, so a torn
    ADD COLUMN z ..., MODIFY ORDER BY (..., z) surfaced through that function reports
    UNKNOWN_IDENTIFIER rather than INCOMPATIBLE_COLUMNS. Misleading message on a path that fails either
    way, no user-reachable consequence; not raised as work.
  • SharedMergeTree is not in this repository. The same attach ordering may exist there; I did not check
    and am not claiming to have.

Checked and found clean

The predicate is exact by construction (the same multi writes the znodes the entry is compared against);
executeMetadataAlter's version guard is <, not <=, so the entry still replays and the queue really
does persist the file; checkTableStructureAttempt never compares metadata_version, so leaving the
in-memory version alone cannot fail the strict check; setProperties opens its own jemalloc MergeTree
arena, so the new attach-thread caller is arena-correct; /queue, /columns, /metadata and
/metadata_version are created in the same multi as /host, so the unguarded reads cannot ZNONODE;
handleTableMetadataMismatch guards its logger, so passing none is supported; the extracted
applyMetadataInMemory is statement-for-statement the old body, including the revert in the catch; and
the adopted state (new structure, old metadata_version) is never visible to a writer, because
tryStartup publishes the replica's committed version into the in-memory metadata before
setNotReadonly runs, so no part is ever stamped with a stale version under the new structure. Crash
sweep across the acknowledged boundaries: every one is self-healing and the change creates no RAM-only
obligation.

Session id: cron:clickhouse-review-slot-8:20260910-131501

@clickhouse-gh clickhouse-gh Bot closed this Sep 10, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. New PAUSEABLE_ONCE failpoint after the Keeper multi, driven by SYSTEM ENABLE FAILPOINT / ALTER ... SETTINGS alter_sync = 0 / SYSTEM WAIT FAILPOINT ... PAUSE, then a SIGKILL restart. No sleeps, no timing dependence; all 7 arms green at --count 20 (140/140), and re-verified on the final binary (7/7 full module, plus 60/60 for the three recovering arms at --count 20).
b Root cause explained? Yes. executeMetadataAlter commits the Keeper half (/replicas/<r>/{columns,metadata,metadata_version} in one multi) and the local metadata file in two separate steps with nothing filesystem-touching in between, so a kill there leaves the znodes ahead of the file. On restart the attach thread runs the structure check against those znodes with strict_check = true, throws INCOMPATIBLE_COLUMNS (or METADATA_MISMATCH), then sets initialization_done, so no retry is scheduled. The throw is upstream of the queue load, so the queued ALTER_METADATA that would write the file never runs.
c Fix matches root cause? Yes. It removes the premature refusal rather than tolerating a mismatch: the check itself is unmodified and still runs, now after adoption. No strict_check argument appears in the fix, no catch block, no error code changed, no setting, no widened bound.
d Test intent preserved / new tests added? Yes. No pre-existing test modified. Seven new integration arms: three recover, four assert that the old refusal still happens - when no queue entry accounts for the divergence, and when each of the three committed znodes the predicate compares (metadata_version, columns, metadata) no longer matches the entry. Each refusing arm mutates exactly one input with kazoo and self-checks that its own rewrite landed, so none can pass vacuously. test_alter_settings_or_comment_on_cluster's documented INCOMPATIBLE_COLUMNS expectation still holds.
e Both directions demonstrated? Yes, and per gate. (1) Adoption disabled: arm 1 fails on is_readonly and the log carries Initialization failed, table will remain readonly. Error: Code: 122 ... Table columns structure in ZooKeeper is different from local table structure. (2) alter_version comparison disabled: test_entry_version_mismatch_still_refuses fails (is_readonly 1 != 0, the replica starts writable) while the payload arm stays green. (3) Both byte comparisons disabled: test_entry_payload_mismatch_still_refuses fails (the entry's column reaches system.columns) while the version arm stays green. (4) ONLY the metadata_str comparison disabled: test_entry_metadata_mismatch_still_refuses fails (the entry's column reaches system.columns) while both other gate arms stay green in the same session. So each of the predicate's three comparisons reddens its own arm and nothing else. With the fix all 7 arms pass 20x; every control build's Build-ID verified different.
f Fix is general across code paths? Fixed at the source (the refusal), not guarded at the throw site. checkTableStructure, checkTableStructureAttempt, checkEquals and checkImmutableFieldsEquals are untouched; the constructor's need_check_structure path and the MOVE PART TO SHARD check on a foreign Keeper path are unaffected (adoption runs only on the attach thread and reads only replica_path). Serialization hints are reset as executeMetadataAlter does, so no window opens before setNotReadonly activates the queue. SYSTEM RESTART REPLICA re-enters the same attach thread and therefore recovers too.
g Fix generalizes across inputs? Yes, by construction rather than enumeration: the adopted value is the entry's whole metadata_str + columns_str, so it is field-agnostic (columns, projections, skip indexes, TTL, sorting key, sampling expression, constraints, index granularity bytes) with no per-field code. Arms cover both reported signatures (columns -> Code: 122; projections -> Code: 342, a different throw site) plus the hardest input class, Keeper metadata referencing a column the local table does not have yet.
h Backward compatible? Nothing engaged: no setting, so no SettingsChangesHistory.cpp entry; no on-disk or Keeper format change; no error-code change. An older binary reading a recovered replica sees an ordinary consistent replica.
i Invariants and contracts preserved? Adoption runs under lockForAlter and publishes through setProperties, which invalidates the sorting-key and patch-parts caches under their own mutexes; hints are reset under lockParts. It writes no znode, removes no queue entry and persists nothing, so a kill in the gap reproduces the same recoverable state and the next start adopts again (idempotent, no marker). The predicate stops matching once the queue acknowledges the entry. metadata_version is deliberately left untouched so cloneMetadataIfNeeded still creates the entry a lost replica needs to persist the file.

Session id: cron:clickhouse-impl-slot-5:20260910-123001

@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [77fdf33]

Summary: ❌

job_name test_name status info comment
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb
Performance Comparison (arm_release, master_head, 1/6) FAIL Performance dashboard
read_in_reverse_order_final #0 FAIL dashboard
read_in_reverse_order_final #1 FAIL dashboard
and_compare_chain_derived #2 unstable query history
file_table_function #5 unstable query history
Performance Comparison (arm_release, master_head, 5/6) FAIL Performance dashboard
array_first_last #9 FAIL dashboard
AST fuzzer (amd_debug, targeted, old_compatibility) ERROR

AI Review

Summary

This PR recovers a ReplicatedMergeTree replica when a metadata ALTER was killed after committing /replicas/<r>/{columns,metadata,metadata_version} to Keeper but before updating the local metadata file. The recovery path is close, but it still publishes the adopted schema before any queue state is loaded, so a later readonly attach failure can expose a schema that the read path cannot actually serve correctly.

Findings

❌ Blockers

  • [src/Storages/StorageReplicatedMergeTree.cpp:2012] adoptCommittedMetadataFromPendingAlter calls applyMetadataInMemory on the attach thread before queue.load() has populated the mutation state that read-time conversions depend on. If a later non-retryable startup step fails first (checkParts, createNewZooKeeperNodes, or any earlier failure before ReplicatedMergeTreeRestartingThread::tryStartup reaches queue.load() at src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.cpp:205-211), ReplicatedMergeTreeAttachThread::run leaves the table readonly but queryable with the adopted metadata already published (src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp:72-90). Reads then build their MutationsSnapshot from an empty queue (src/Storages/MergeTree/MergeTreeData.cpp:14313-14325), so getAlterConversionsForPart has no pending rename/drop/READ_COLUMN commands to apply (src/Storages/MergeTree/MergeTreeData.cpp:13615-13617). That leaves queries against parts written under the old schema using the new metadata without the required conversions; e.g. a queued RENAME COLUMN no longer maps the new name back to the old on-disk column in injectRequiredColumnsRecursively (src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp:102-109). Suggested fix: keep the adopted metadata private until tryStartup has loaded the queue, or revert the in-memory adoption on every attach-thread failure path that exits before queue.load().
Tests
  • The new integration suite proves the recovery for ADD COLUMN, sorting-key, and projection metadata, but it still does not cover an interrupted metadata ALTER whose correctness depends on queued read-time conversions (RENAME COLUMN, DROP COLUMN, lazy ALTER MODIFY COLUMN). That is the path still broken by the blocker above.
Final Verdict

Changes required before merge: the adopted schema must not become visible on a readonly startup path until the queue state that supplies the matching read-time conversions has been loaded.

LLVM Coverage Report

Measured on commit 77fdf33.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.80% +0.10%
Branches 79.50% 79.50% +0.00%

Changed lines: Changed C/C++ lines covered: 81/83 (97.59%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @tavplubix @alesapin, could you review this? A metadata ALTER commits to Keeper and to the local metadata file in two separate steps, so a kill in between leaves this replica's znodes ahead of its own file and the attach thread's strict structure check then refuses on every restart, with no retry ever scheduled. This adopts the replica's own committed Keeper metadata in memory when a queued ALTER_METADATA entry in its queue accounts for it byte-for-byte, and leaves the writing of the file to the queue as usual.

@clickhouse-gh clickhouse-gh Bot added the comp-replication ReplicatedMergeTree* + replication log/state transitions, eventual consistency mechanics. label Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 77fdf33ffa5bd03b8da2eef79ae40815857c5bc5 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception).

See the job log for details.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - b383510

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 3/6) / test_partition_pruning_with_functions_before_epoch[local, s3] master-side regression, not reachable from this branch's diff #119298 (external, merged 17:26:35Z), merged master @ aea159d to pick it up
Finish Workflow / Post Hooks derived: the shard red DROPPED both Bugfix validation (integration tests, *) legs, so no per-arch leg could report OK #119298 (external, merged), merged master @ aea159d
Mergeable Check / PR aggregators rolling up the rows above, no independent failure #119298 (external, merged), merged master @ aea159d

Root cause, measured: #118606 ("Proper partition pruning with dates", merged 13:52:27Z) broke
test_storage_iceberg_with_spark partition pruning fleet-wide, 230 CIDB failure rows across 33
pull requests plus 7 true-master trees today, first firing 14:34Z. @ Algunenano reverted it in
#119298 at 17:26:35Z. This branch's integration leg started 16:03Z, i.e. before the revert landed,
so I merged master (9b9f4d3aa2ad, which contains the revert) and pushed
aea159d923071cedf3528005d106f312b471adb6 so CI re-runs with it. The merge changes nothing of my
own diff: the same 6 files, +532/-7, zero-context patch-id
47de16d1c83b6b6c159ac13857f4f328bee4aa23 unchanged.

The 124 skipping check-runs on this head are praktika's normal skip state, not failures: the
rollup was 46 pass / 4 fail / 124 skipping.

Session id: cron:our-pr-ci-monitor:20260910-190047

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - aea159d

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_debug, parallel) / 05141_time_series_select_join_settings trunk regression from merged #117356, first failure on master 2026-09-10 17:40:24Z (189 true-master rows, 45 unrelated pull requests) #119334 (external, merged 19:22:08Z) reverted the cause on master and is NOT in the tree this run built (ledger rule 3c, not 3d)
Stateless tests (arm_binary, parallel) / 05141_time_series_select_join_settings same trunk regression #119334 (external, merged)
Stateless tests (arm_asan_ubsan, targeted) / 05141_time_series_select_join_settings (5 repeats), Too many test failures same trunk regression; all 5 failures are repeats of that one test and the abort row is this job's own --max-failures early stop #119334 (external, merged)
Finish Workflow / Post Hooks rollup: new_tests_check.py reports the stateless jobs above #119334 (external, merged)
Sync - CH Inc sync (private, not actionable by me)

Not caused by this pull request. The boundary is measurable: 05141_time_series_select_join_settings
first failed on master at 17:40:24Z, #119334 (the automatic Revert CI regressions revert of #117356)
merged at 19:22:08Z, and praktika pins the merge ref when Config Workflow starts. This workflow was
dispatched at 19:19:02Z, before that merge. Every one of my open pull requests dispatched after it passes
these same jobs (11 heads checked), and every one dispatched before it fails them.

A master merge is therefore owed here to re-run CI on a tree that contains the revert; nothing else
re-dispatches these jobs. PR and Mergeable Check are praktika rollups of the rows above, not
separate failures. Note that #119335 re-lands #117356 and carries the same test file, so the merge is
stable in both worlds.

Session id: cron:our-pr-ci-monitor:20260911-010040

@groeneai

Copy link
Copy Markdown
Collaborator Author

Master merged to pick up #119334, the action the ledger above said was owed: aea159d92307..ad767625384f, fast-forward, no source change.

The revert is live in the tree this run builds: src/Interpreters/SpillingHashJoin.cpp is 15756 bytes at ad767625384f and at the master tip, against 17607 bytes at the revert's first parent.

My contributed diff is byte-identical across the merge, so there is nothing new to re-read: same zero-context patch-id 47de16d1c83b, same per-file changed-line hashes for all six files, same +532/-7 diffstat, no submodule pin change, no conflicts.

CI is running on ad767625384f (workflow run 34551083914).

metadata_from_entry, current_metadata->columns, current_metadata->virtuals, getStorageID().getNameForLogs(), getContext());
/// Not pending_alter->alter_version: cloneMetadataIfNeeded skips the ALTER_METADATA entry it
/// creates for a lost replica once the in-memory version already equals the source's.
applyMetadataInMemory(

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.

Publishing the adopted schema under current_metadata->getMetadataVersion() is only safe if the attach path is guaranteed to reach startupImpl() and queue.load() before the table becomes queryable. That is not true here: adoptCommittedMetadataFromPendingAlter runs before checkParts() / createNewZooKeeperNodes(), and any later non-retryable exception makes ReplicatedMergeTreeAttachThread::run set initialization_done = true and return without ever loading the queue.

At that point startup() has already returned from waitFirstTry(), and read() can serve the table in readonly mode. For ALTERs that rely on queued metadata conversions (RENAME COLUMN, DROP COLUMN, MODIFY COLUMN via READ_COLUMN), the adopted schema is now visible with the old metadata_version and an empty mutations snapshot, so selects skip the queued ALTER conversions and read old parts as if they already matched the new schema. Can we keep the adopted metadata local until tryStartup() has loaded the queue, or revert it on any attach-thread failure before then?

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ad76762

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Logical error: 'Got read request from replica 0 for unknown stream <db>.t_mt_index_rp.' (STID 5217-505b) trunk regression, not this PR: abort at ParallelReplicasReadingCoordinator::handleRequest (ParallelReplicasReadingCoordinator.cpp:1316) reached via RemoteQueryExecutor::processMergeTreeReadTaskRequest, in the upgrade check's pre-upgrade load #119406 (mine, open)
PR rollup of the check above #119406 (mine, open)

This signature has been firing in Upgrade check (amd_release) across a large set of unrelated pull requests since ~04:00Z today, always on stream t_mt_index_rp, and this branch changes replicated-metadata startup (StorageReplicatedMergeTree, ReplicatedMergeTreeAttachThread, FailPoint) rather than anything in the parallel-replicas read path. #119406 stops the upgrade check from shipping serialized query plans in that pre-upgrade load, which is the setting interaction that produces the divergent reading mode behind this abort.

Session id: cron:our-pr-ci-monitor:20260911-083121

…mmitted-metadata-on-interrupted-alter

# Conflicts:
#	src/Storages/StorageReplicatedMergeTree.cpp
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 77fdf33

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log (see upgrade_error_messages.txt) MutateFromLogEntryTask: Code: 40 ... Checksums of parts don't match: hash of uncompressed files doesn't match. The upgrade runner draws default_compression_codec again on its second configure, and in this job it changed from ZSTD(3) (previous release, 16:28:30) to LZ4 (new server, 16:50:14), so a part mutated after the restart is not byte-identical to the copy on the other replica. The same error failed this check on 12 distinct PRs in the last 7 days, this one included #121249 (mine, open)
AST fuzzer (amd_debug, targeted, old_compatibility) job-level ERROR, not a fuzzer finding: the fuzz run ended cleanly (exit 143 at the 30 min budget), then the post-fuzz liveness probe clickhouse-client ... --query 'SELECT 1' printed 1 and the script never got past that call, so the job was killed at the 18000 s job timeout about 4.5 hours later. The same wedge happened on master on 2026-09-24 in AST fuzzer (amd_release, oracle), and #115915, which bounded this probe, is present in both trees a fix task is created (investigating at full effort, fixing-PR link to follow here)
Performance Comparison (arm_release, master_head, 1/6) / read_in_reverse_order_final #0, #1 dashboard confirmed_regression, client_time +49.4% and +33.8%. On master these two FINAL queries over a plain ReplacingMergeTree went from 2-3 ms to 8-9 ms at the merge commit of #122073 (302e001eeb33), which stopped background merges during the measured runs. #0 was flagged slower or unstable on 57 PRs and 9 master runs in the last 7 days a fix task is created (investigating at full effort, fixing-PR link to follow here)
Performance Comparison (arm_release, master_head, 5/6) / array_first_last #9 dashboard confirmed_regression, client_time 0.0543 -> 0.0652 (+20.2%). The fixture reads Memory tables, which this PR's replicated startup code never touches, and the query was flagged slower or unstable on 14 PRs and 6 master runs in the last 7 days ClickHouse/performance-comparison#5 (external): the dashboard's confidence scoring, where @ fm4v handles these verdicts. That repository is not publicly readable, so its state cannot be measured from here
Mergeable Check, PR rollup rows, red only because of the four checks above #121249 (mine, open), ClickHouse/performance-comparison#5 (external) and a fix task is created, the same owners as the four rows above

All 173 check runs completed, and Finish Workflow and CH Inc sync are green on this head.

Session id: cron:our-pr-ci-monitor:20260925-203211

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the read_in_reverse_order_final Performance Comparison rows created: #122335

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the AST fuzzer (amd_debug, targeted, old_compatibility) job timeout created: #122353

pull Bot pushed a commit to erickirt/ClickHouse that referenced this pull request Sep 26, 2026
…ness's own queries

After a clean fuzz run (`Fuzzer exit code is 143`), the post-fuzz liveness
probe `clickhouse-client --handshake_timeout_ms=30000 --receive_timeout=5
--query 'SELECT 1'` sometimes never returns. status.tsv is then never
written, praktika kills the job at its 18000 s timeout before any artifact
is uploaded, and the job reports a bare ERROR with no server log. Five such
runs in 45 days: PR ClickHouse#112304 (2026-08-18), PR ClickHouse#98670 (2026-08-19), PR ClickHouse#115530
(2026-08-20), true master 9816d0a `AST fuzzer (amd_release, oracle)`
(2026-09-24) and PR ClickHouse#119237 `AST fuzzer (amd_debug, targeted,
old_compatibility)` (2026-09-25). Only the last one printed the `1`.

Two harness defects make the probe unbounded.

(a) The probe is itself fuzzed on the server. query-fuzzer-tweaks-users.xml
sets ast_fuzzer_runs=5 and ast_fuzzer_any_query=true on the `default`
profile, and no harness-owned client call opted out. The server runs the
mutated copies in a query-finish callback, and TCPHandler calls
io.onFinish() after sending the data and before EndOfStream, so a fuzzed
follow-up that does not finish holds the reply open after the `1` was
printed. The same pin was part of ClickHouse#113248, which was closed as already
integrated, but its run-fuzzer.sh half never reached master. The stress
harness (ClickHouse#114127), the log export (ClickHouse#117996) and tests/clickhouse-test
already pin it.

(b) --receive_timeout does not bound the probe either. On a receive
timeout ClientBase::receiveResult only records TIMEOUT_EXCEEDED and cancels
the query; from then on it polls the connection until the server sends a
packet, with no bound. A server whose connection thread never gets back to
the socket holds the probe forever, which is what the four runs that
printed nothing show.

Pin --ast_fuzzer_runs=0 on every harness-owned client call through one
variable; the fuzzer's own client stays unpinned. Run the two post-fuzz
probes (the restart liveness check and the probe loop) under
`timeout --signal TERM --kill-after=10 60`. A probe killed by timeout
(rc 124, or 137 after the kill) is counted like the client's own
"Timeout exceeded while", so a server that stops answering reaches the
existing "treating server as hung" verdict after 12 retries (about
14 minutes) and the job keeps its logs. 60 s covers the probe's own worst
case (30 s handshake, 5 s receive timeout, the cancel round trip) with room
for a slow sanitizer server. The fallback branch now prints the probe's
exit code instead of the last grep's.

The pre-fuzz probes are not wrapped: the check after attaching gdb waits
for gdb to load debug info on purpose, and the server is fresh there.

One server-side hang the fuzzer produces, a self-deadlock when one query
builds two system.stack_trace sources, is fixed separately in ClickHouse#120216.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-replication ReplicatedMergeTree* + replication log/state transitions, eventual consistency mechanics. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant