Skip to content

Fix flaky test_keeper_4lw_reconfiguration when the node receiving rcfg briefly has no live leader - #122495

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-keeper-4lw-rcfg-no-live-leader
Sep 27, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-keeper-4lw-rcfg-no-live-leader

Conversation

@groeneai

@groeneai groeneai commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #113988

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

test_no_remove_itself failed in Integration tests (amd_tsan, 4/6) (report) on #122464, which does not touch Keeper:

AssertionError: assert 'Reconfigure command cannot remove current server id' in 'Code: 36. DB::Exception: Cannot reconfigure cluster because there is no active leader. (BAD_ARGUMENTS) (version 26.10.1.1)'

The test sends rcfg and assumes the receiving node sees a live leader at that moment. Here the leader's heartbeats to node3 paused for 1.64 s, longer than node3's election timeout. node3 cleared its leader and, because of its low priority, did not start an election. The next heartbeat made it a follower again, but NuRaft marks the leader alive only on the heartbeat after that (become_follower does not set hb_alive_, update_target_priority does), so for about one more heartbeat interval node3 reported no live leader, and rcfg refuses to run then. The cluster itself was healthy: the next test saw leader 7 and all 5 members.

Both no-live-leader refusals (the entry check of KeeperDispatcher::reconfigureClusterFromReconfigureCommand and the leaders precondition) are raised before any action is applied, so the command can be sent again. The new helper send_rcfg resends only on those two messages, every 0.5 s for up to 30 s, then fails with the last refusal. All five rcfg calls use it, and every assertion is unchanged. A NuRaft fix for hb_alive_ would only shorten this window: until the first heartbeat after the gap, node3 has no leader at all.

Validated by blocking node3 <-> leader with iptables for 3 s while the two tests send rcfg: without the change both fail with the CI message, with it both pass (3 of 3 runs, 11-12 resends each). Disabling the retry match, or setting the deadline to 0, turns both red again. The module passes 5 of 5 fresh-cluster runs without the fault.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.847-master (included in 26.10 and later)

…g briefly has no live leader

The test sends `rcfg` and assumes the receiving node sees a live leader at
that moment. A leader heartbeat gap longer than the election timeout makes a
follower clear its leader. The next heartbeat makes it a follower again
without marking the leader alive (NuRaft's same-term candidate branch calls
only become_follower(), and only update_target_priority() sets hb_alive_),
so for about one more heartbeat interval KeeperDispatcher refuses the command
with "Cannot reconfigure cluster because there is no active leader". Seen in
Integration tests (amd_tsan, 4/6) on PR ClickHouse#122464.

Both no-live-leader refusals (the entry check and the `leaders` precondition)
are raised before any action is applied, so add a helper that resends the
command on exactly these two messages, every 0.5 s for up to 30 s, and then
fails with the last refusal instead of returning it. All five rcfg calls use
it; the assertions are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding; 1 full pass).

# Sev Finding Verdict Evidence / action
1 ⚠️ No committed test proves that send_rcfg retries the no-live-leader refusals, so the loop could silently become a no-op (test.py:51-72) DISAGREE Measured under an iptables node3 <-> leader cut: with the retry match disabled (the no-op case) both faulted tests fail with the CI message; with it they pass (3 of 3 runs, 11-12 resends each). Three calls already assert non-retryable errors, which a retry-everything bug would fail at the 30 s deadline. A mocked send_4lw_cmd could not catch a server-side rewording, and a committed partition test would be a new timing-dependent test. No change.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-9:20260927-013200

@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [421502d]

Summary: ✅


AI Review

Summary

This PR wraps the rcfg calls in test_keeper_4lw_reconfiguration with a retry loop that only resends when the target Keeper briefly reports no live leader. That matches the two server-side refusal paths in KeeperDispatcher that happen before any reconfiguration action is applied, so the retry does not mask partial progress. I did not find an actionable correctness, coverage, or metadata issue in the current diff.

Final Verdict
  • Status: ✅ Approve

@alexey-milovidov alexey-milovidov self-assigned this Sep 27, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 27, 2026
Merged via the queue into ClickHouse:master with commit 6ae1e3a Sep 27, 2026
172 of 173 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 27, 2026
@clickhouse-gh clickhouse-gh Bot added comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... and removed comp-testing Test content only (no production code). 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-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants