Skip to content

Retry tests on the "Coordination error:" rendering of transient Keeper errors - #107042

Merged
alexey-milovidov merged 9 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-clickhouse-test-keeper-retry-match
Sep 7, 2026
Merged

alexey-milovidov merged 9 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-clickhouse-test-keeper-retry-match

Conversation

@groeneai

@groeneai groeneai commented Jun 10, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

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

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

...

Description

The functional test runner (tests/clickhouse-test) retries a test when its output matches an entry in MESSAGES_TO_RETRY. The two transient-Keeper entries only match the socket-layer rendering Coordination::Exception: Session expired / Coordination::Exception: Connection loss.

Generic Keeper operations (exists/get/getChildren) throw via the Coordination::Exception(code) / fromPath(code, path) constructors, which format the message as "Coordination error: {}". The client then prints:

Code: 999. Coordination::Exception: Coordination error: Session expired, path /zookeeper/.../replicas/1/is_active. (KEEPER_EXCEPTION)

That string is not a substring of the existing retry entries, so the runner never retried it and the test failed instead.

This is the OPTIMIZE wait path in StorageReplicatedMergeTree (tryWaitForReplicaToProcessLogEntry -> getZooKeeper()->exists(.../is_active)), which surfaced as a flaky failure of 03100_lwu_29_concurrent_merges on amd_tsan during OPTIMIZE TABLE (reported on #80416). The same Coordination error: rendering also hit test_drop_database_replica and test_distributed_ddl_parallel.

Fix: add the Coordination error: ... variants so both renderings are retried. The existing entries are kept so the socket-layer rendering stays covered. No test reference file contains these strings, so there is no false-positive risk.

Regression coverage: tests/queries/0_stateless/05059_clickhouse_test_keeper_retry_matching.sh loads tests/clickhouse-test as a module and checks need_retry on both renderings of Session expired / Connection loss and on output that must not be retried, so every functional-test job executes it.


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

Version info

  • Merged into: 26.9.1.905 (included in 26.9 and later)

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. The failure is a string-match bug, so the repro feeds the exact CI error strings through the runner's retry predicate (any(msg in text for msg in MESSAGES_TO_RETRY)). The amd_tsan OPTIMIZE error Code: 999. Coordination::Exception: Coordination error: Session expired, path /zookeeper/.../replicas/1/is_active. (KEEPER_EXCEPTION) is not matched by the pre-fix list, so the runner does not retry and the test fails. Deterministic, not probabilistic.
b Root cause explained? optimize() -> waitForLogEntryToBeProcessedIfNecessary -> tryWaitForReplicaToProcessLogEntry makes raw getZooKeeper()->exists(.../is_active) calls. Under the test's 3s rmt_merge_task_sleep_in_prepare failpoint plus TSan thread-fuzzer load, a ZK session expiry throws via Coordination::Exception(code), whose message is formatted as "Coordination error: {}" (KeeperException.cpp:35). The client renders name() + ": " + displayText = Coordination::Exception: Coordination error: Session expired. The existing MESSAGES_TO_RETRY entry Coordination::Exception: Session expired is not a substring of that (the words Coordination error: sit in between), so the generic runner retry never fires.
c Fix matches root cause? Yes. The fix adds the Coordination error: Session expired / Coordination error: Connection loss substrings that match the generic-operation rendering. It directly targets the string-match gap from (b), not a symptom.
d Test intent preserved / new tests added? Preserved. The existing two entries are kept (socket-layer rendering still covered) and two variants are added. The change is to the runner's transient-error retry list, which does not weaken any test's assertions. Following the precedent of the prior MESSAGES_TO_RETRY extension (commit 64aaaef, +3 lines, no test), no separate regression test is added; the runner is a 6000-line non-importable script with no self-test harness. The exact-string repro harness exercises the predicate.
e Both directions demonstrated? Yes. Before fix: the amd_tsan Coordination error: Session expired string is NOT RETRIED (test fails). After fix: all four renderings (form-1 and form-2, for both Session expired and Connection loss) are RETRIED. Verified by running the predicate against the exact CI strings.
f Fix is general, not a narrow patch? Yes. This fixes the root cause in the runner for every test hitting transient Keeper errors, not just 03100_lwu_29_concurrent_merges. CIDB (30d) shows the unmatched Coordination error: rendering also hit test_drop_database_replica and test_distributed_ddl_parallel. Both exists/get/getChildren constructors (Exception(code) and fromPath) are covered. No .reference file contains these strings, so no false positives.

Session id: cron:clickhouse-worker-slot-0:20260610-164600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus for a review — small one-line addition to MESSAGES_TO_RETRY in tests/clickhouse-test so the runner retries the Coordination error: Session expired / Coordination error: Connection loss rendering thrown by generic Keeper operations (the existing entries only matched the socket-layer rendering). Context and root cause are in the description and the validation-gate comment above.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [46e0289]

Summary: ✅


AI Review

Summary

This PR widens tests/clickhouse-test retry matching for transient Keeper Session expired / Connection loss failures so the runner also catches the Coordination error: rendering from generic Keeper operations, and it adds a stateless regression test that exercises the real need_retry predicate on both positive and negative cases. The current code matches the stated root cause, the previously reported coverage gap is fixed, and I did not find remaining review findings in the live diff.

Final Verdict

✅ Approved

LLVM Coverage Report

Measured on commit 46e0289.

Metric Baseline Current Δ
Lines 88.80% 88.80% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.20% 81.10% -0.10%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +859 lines in 209 files (-1025 lines lost coverage) · Details

Full report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI fully finished on c24c47b34140. The only failures are on Stateless tests (arm_asan_ubsan, azure, parallel), which is a box-wide Azure infrastructure outage today, not this change. In the last 12h the same arm_asan_ubsan, azure, parallel lane failed across 25+ unrelated PRs and master, each with dozens of distinct tests failing (Azure timeouts / "Server died" / memory-limit), e.g. 83, 58, 52, 41, 40 distinct-test failures on different PRs in the same window.

This PR only adds two transient-Keeper-error renderings (Coordination error: Session expired / Connection loss) to tests/clickhouse-test MESSAGES_TO_RETRY and cannot cause Azure stateless failures. All other jobs pass on this commit.

Session id: cron:our-pr-ci-monitor:20260610-225430

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks ok

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jun 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Added a regression test (ci/tests/test_clickhouse_test_keeper_retry.py) that loads the real tests/clickhouse-test runner and asserts need_retry() matches both renderings of a transient Keeper error:

  • socket-layer: Coordination::Exception: Session expired / Connection loss
  • generic operation-level (the fromPath/default ctor, which prepends Coordination error: ): Coordination::Exception: Coordination error: Session expired[, path ...]

Verified both directions against the real runner: with only the original two substrings, the generic-form assertion FAILS (all 3 generic renderings return need_retry=False); with the two Coordination error: ... entries added by this PR, all forms return True. The test also asserts an unrelated DB::Exception is not retried. This locks in the two-format match so the single-format gap cannot silently reappear.

The push also re-runs CI on a current base; the earlier red on Stateless tests (arm_asan_ubsan, azure, parallel) was the 2026-06-10 box-wide Azure outage, unrelated to this one-list change.

groeneai and others added 2 commits July 16, 2026 11:30
…r errors

The functional test runner retries a test when its output matches an entry in
MESSAGES_TO_RETRY. The two Keeper entries added previously only match the
socket-layer rendering "Coordination::Exception: Session expired" /
"Coordination::Exception: Connection loss".

Generic Keeper operations (exists/get/getChildren) throw via the
Coordination::Exception(code) / fromPath(code, path) constructors, which format
the message as "Coordination error: {}", so the client prints
"Coordination::Exception: Coordination error: Session expired, path ...". That
string is not a substring of the existing retry entries, so the runner never
retried it and the test failed instead.

This is exactly the OPTIMIZE wait path in StorageReplicatedMergeTree
(tryWaitForReplicaToProcessLogEntry -> getZooKeeper()->exists(.../is_active)),
which surfaced as a flaky failure of 03100_lwu_29_concurrent_merges on amd_tsan
(Code: 999. Coordination::Exception: Coordination error: Session expired, path
/zookeeper/.../replicas/1/is_active. (KEEPER_EXCEPTION) during OPTIMIZE TABLE).

Add the "Coordination error: ..." variants so both renderings are retried. The
existing entries are kept so the socket-layer rendering stays covered.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Loads the real tests/clickhouse-test runner and asserts need_retry()
returns True for both the socket-layer ("Coordination::Exception: <msg>")
and the generic operation-level ("Coordination error: <msg>") renderings
of transient Keeper errors, and False for an unrelated error. Guards the
two-format match so the single-format gap cannot silently reappear.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/fix-clickhouse-test-keeper-retry-match branch from a1e0e97 to 2be2c3f Compare July 16, 2026 11:31
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2be2c3f

CI is fully finished on this head and there is nothing to own: 0 failures, 177 checks completed, Finish Workflow, Config Workflow, Style check and Fast test all green.

This supersedes the earlier ledger on c24c47b34140, which predated the 2026-07-16 rebase onto master.

Session id: cron:our-pr-ci-monitor:20260828-010000

The private sync PR was closed on 2026-08-25 while this pull request was still open, and
GitHub refuses to reopen it, so `CH Inc sync` was stuck at `awaiting` with no sync branch
and no private CI. The stale branch is deleted; this commit gives the synchronizer a fresh
update to recreate the sync pull request from.
@alexey-milovidov alexey-milovidov self-assigned this Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 021bcc6

Every failure below has an owner: a fixing PR (ours 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
Stress test (arm_asan_ubsan) / Logical error: 'Not-ready Set is passed as the second argument for function 'globalNotIn'' (STID 0250-4e52) logical error in _path virtual-column filtering for object storage, reached while building the read pipeline #112968 (external, open)

The only red at this head, and not caused by this PR: the whole diff here is tests/clickhouse-test,
a test-runner change that adds a retry on the Coordination error: rendering of transient Keeper
errors. It cannot alter server-side set building.

Owner attribution, since the STID alone does not settle it: that bucket pools more than one defect,
so I resolved this by stack and by carrier instead. The abort goes
Functions/in.cpp:128 under VirtualColumnUtils::filterBlockWithExpression,
getFilterByPathAndFileIndexes, filterByPathOrFile,
StorageObjectStorageSource::createFileIterator and
ReadFromObjectStorageStep::initializePipeline, which is the object-storage _path filtering path
that #112968 rewrites, and the failing query's log_comment names
05043_object_storage_path_virtual_column_empty_namespace.sh, i.e. a test whose whole subject is
the object-storage _path virtual column. The other candidate in the same bucket, the general
in-place set-build restore, is a draft and does not match this stack.

Session id: cron:our-pr-ci-monitor:20260831-120000

The AI review asked for CI-executed coverage of the new `Coordination error:`
entries in `MESSAGES_TO_RETRY` after the earlier `ci/tests` unit test was
removed together with that directory. A stateless shell test now loads
`tests/clickhouse-test` as a module and feeds both renderings of transient
Keeper errors through `need_retry`, plus unrelated output that must not be
retried. The test fails against the runner on master and passes with this
branch.
@groeneai

groeneai commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 80be8ad

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
LLVM Coverage / Generate LLVM Coverage Diff Report, then Print Uncovered Code as its cascade master-side, not this diff: praktika's static S3 prefix gained an unconditional workflow-name segment in #110081, which orphaned the hand-spelled coverage baseline key, so the 100-commit baseline walk finds nothing and the uncovered-code step never runs. 67 distinct pull requests carry it since 2026-09-02 13:07:52Z, and 0 of 184 true-master runs of this check fail #117718 (external, open)
Stress test (arm_release) / Logical error: Join is supported only for pipelines with one output port, got A and B (STID 4488-4e11) pre-existing trunk defect, thrown at src/QueryPipeline/QueryPipelineBuilder.cpp:373 and :414. Not reachable from this diff, which is test-harness only: two added strings in MESSAGES_TO_RETRY plus a new stateless test, and a retry-matching string can only make the runner more tolerant of an already-failed test, never produce a pipeline abort. 34 distinct pull requests carry the STID over 21 days #109393 (mine, open)
Sync - CH Inc sync (private, not actionable by me)

On the second row, #115352 (merged 2026-08-19T22:15:36Z) is deliberately not named as the owner.
It is the sibling fix for this family and it did close the master-reachable sub-shape: splitting the
STID's history at its merge gives 32 pull requests and 3 true-master hits before, and 14 pull
requests with 0 true-master hits after. But it is present in this tree and the abort happened
anyway, probed at the tree that actually ran rather than inferred from timing: pre-fix 52c86bd379f3
= 0, at the fix 0a03d0a8d6f6 = 1, this head 80be8adaeaff = 1 (ahead_by 7013, behind_by 0). So
the residual sub-shape is owned by #109393, which changes the file that throws.

Session id: cron:our-pr-ci-monitor:20260902-200000

@abashkeev abashkeev added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026
Master already carries fourteen `05059_*` tests; move the new one to the next free prefix.
@groeneai

groeneai commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 0f2b8c2

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 (arm_asan_ubsan, azure, sequential) / 04648_distributed_plan_task_error_propagation public master regression with a hard onset today: a recorded CANNOT_SCHEDULE_TASK is lost and the client sees POCO_EXCEPTION 1000 instead. 12 carrier PRs and 3 true-master rows in 30d, every one of them after 01:34Z on 2026-09-06 #118390 (mine, open)
Stateless tests (arm_asan_ubsan, azure, sequential) / 04340_distributed_plan_status_reenqueue_fault collateral of the row above inside the same sequential job: 04648 arms a REGULAR failpoint and exits without disabling it, so the recordFailure log line 04340 asserts on never appears #118390 (mine, open) removes the trigger; #105942 (external, open, approved) resets leaked failpoints at the runner layer
PR status context aggregating the single failing job above #118390 (mine, open)

Not caused by this PR. Its only runner change adds two strings to MESSAGES_TO_RETRY in tests/clickhouse-test, which decides whether an already-failed test is retried and cannot reach the distributed plan executor. Both tests also fail on true master, where this diff is absent.

CH Inc sync, Mergeable Check and Style check are green at this head, so no exempt row is owed. This supersedes the ledger posted for 80be8adaeaff; the head has since moved to 0f2b8c2f36f9.

Session id: cron:our-pr-ci-monitor:20260906-163035

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 7, 2026
Merged via the queue into ClickHouse:master with commit 4a1f810 Sep 7, 2026
175 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 7, 2026
@clickhouse-gh clickhouse-gh Bot added comp-testing Test content only (no production code). and removed comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 22, 2026
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-testing Test content only (no production code). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants