Repository navigation
Fix flaky 01396_inactive_replica_cleanup_nodes_zookeeper - #107062
alexey-milovidov merged 2 commits into
Conversation
The cleanup-wait loop read numChildren with stderr suppressed (2>/dev/null) and compared it with [[ $count -lt $((SCALE / 4)) ]]. On a transient empty read the variable is empty, and in bash [[ "" -lt N ]] evaluates to true, so the loop broke immediately, before the ZooKeeper log had been trimmed. The assertion that follows then printed 0 instead of 1, producing the observed "result differs with reference" failure (only the first output line flips 1 -> 0; the is_lost lines are unchanged because cleanup completes in the gap before they run). This matched every failing run in CIDB and explains the low rate: the empty-read window is only the brief interval before cleanup fires, which is wider on loaded arm_binary runners. Require count to be a non-empty integer before the comparison so a transient empty read keeps polling instead of breaking early. The assertion and its threshold are unchanged, so the test still fails if cleanup never happens. Verified locally: with the old logic a forced empty read on the first iteration reproduces the failure (7/10); with the guard it passes (15/15). Closes: ClickHouse#106297 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-21:20260610-184200 |
|
Workflow [PR], commit [684a339] Summary: ✅ AI ReviewSummary
Final Verdict
|
|
CI fully finished (Finish Workflow passed) on d74fb2c. The single failure is Stateless tests (arm_asan_ubsan, azure, sequential) -- the known azure-infra-outage / db-disk "Server died" chronic class, unrelated to this PR (which fixes the flaky 01396_inactive_replica_cleanup_nodes_zookeeper itself). Not PR-caused. No Fast/Bugfix/Style failure. Ready for review. |
|
@groeneai, Azure infra has been fixed, please update the branch. |
|
@groeneai, do you know why the query can return an empty result? This sounds strange. |
…ctive-replica-cleanup-empty-read
|
@alexey-milovidov Branch updated: merged current master and pushed, CI is re-running. On the empty result, you are right to be suspicious. It is not a legitimately empty row. The poll query is So an empty stdout is a suppressed error, not an empty row. The poll uses The fix keeps the loop polling until it gets a real reading ( |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 490 line(s), 50 function(s) across 133 file(s) · Details Top files
|
|
Let's do it in two steps.
|
|
@alexey-milovidov Sounds good, thanks for merging step 1. For step 2 I'll open a follow-up PR that hardens 01396 to surface the poll errors instead of swallowing them. One constraint shapes the approach: clickhouse-test fails a .sh test on any non-empty stderr, so simply removing the So instead I'll capture the in-loop poll errors and surface them (plus the last numChildren reading) only when the wait never converges. A healthy run stays byte-identical and quiet; a genuinely broken run now fails with the real Keeper/client error visible instead of a silent wrong count. I'll link the PR here. |
|
Step 2 follow-up: #108213 (hardens 01396 to surface the poll errors instead of swallowing them). |
…rrors Follow-up to ClickHouse#107062, which made the cleanup-wait loop require numChildren to be a non-empty integer before comparing (a transient empty read had let [[ "" -lt N ]] break the loop early). That stabilized the test but still discarded the underlying read error via 2>/dev/null. The numChildren poll is served by StorageSystemZooKeeper: tryGetChildren on the table root, tryGet on each child for its stat, then the name='log' predicate. The only errorless zero-row paths are root-ZNONODE or /log-ZNONODE, but both are permanent structural ReplicatedMergeTree nodes for the whole test (DROP only at the end). So a successful query always returns exactly one numeric row, and an empty count is a suppressed transient error (a Keeper/client hiccup under the heavy single-row INSERT load), not an empty result. Capture the poll's stderr per iteration and, if the loop never converges, print the last error and last count to stderr so the real failure is diagnosable. clickhouse-test fails a .sh test on any non-empty stderr, so a healthy run stays byte-identical and silent; only a genuinely stuck wait now fails with the underlying error exposed instead of a silent wrong count. The temp file uses CLICKHOUSE_TEST_UNIQUE_NAME so the test stays parallel-safe. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes flaky
01396_inactive_replica_cleanup_nodes_zookeeper(issue #106297).The cleanup-wait loop reads
numChildrenwith stderr suppressed and compares with[[ $count -lt $((SCALE / 4)) ]]. On a transient empty read$countis empty, and[[ "" -lt N ]]is true in bash, so the loop broke immediately before the ZooKeeperlogznode was trimmed. The following assertion then printed0instead of1.This matches every failing run in CIDB: only the first output line flips
1->0; theis_lostlines are unchanged because cleanup completes in the gap before they run. It also explains the low rate (the empty-read window is only the brief interval before cleanup fires, which is wider on loadedarm_binaryrunners).Fix: require
countto be a non-empty integer before the comparison, so a transient empty read keeps polling instead of breaking early. The assertion and threshold are unchanged, so the test still fails if cleanup never happens.Verified locally: with the old logic a forced empty read on the first iteration reproduces the failure (7/10); with the guard it passes (15/15).
Version info
26.6.1.1131