Skip to content

Fix flaky test_batch_set_processing_failure_does_not_crash on 25.8 - #113728

Closed
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-batch-set-processing-25.8
Closed

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-batch-set-processing-25.8

Conversation

@groeneai

@groeneai groeneai commented Aug 6, 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

This test is red about half the time on 25.8: over the 60 days to 2026-08-06 08:00 UTC, 15 FAIL /
20 OK there, across five failing PRs and six branch-side runs. master is 0 FAIL over thousands of
OK runs, and 26.x is zero.

Root cause, in the test rather than the engine. The test plants a Keeper conflict node at the
hard-coded path {keeper_path}/processing/{node} so the engine's tryMulti fails and
ObjectStorageQueueFailedToBatchSetProcessing increments. On 25.8 that directory is chosen at
runtime from use_persistent_processing_nodes
(ObjectStorageQueueUnorderedFileMetadata.cpp:32 -> ObjectStorageQueueIFileMetadata.cpp:203-205),
which the shared helper randomizes (helpers/s3_queue_common.py:172, :125 on 25.8). On the losing
draw the engine uses persistent_processing, so the planted node is inert and the counter cannot rise.

The change pins use_persistent_processing_nodes = 0 in the test's additional_settings, beside
the existing list_objects_batch_size pin for the same class of hazard;
settings.update(additional_settings) runs after the draw, so the value wins, and test_5.py pins it
too. No assertion is weakened and no no-random-* tag is added: this suite's other 95 unpinned
create_table sites keep the draw live.

Why this targets master, which is green. There the processing directory is the compile-time
literal "processing" (ObjectStorageQueueUnorderedFileMetadata.cpp:27) and the CREATE-time value
is never consumed: the metadata constructor gets a literal true
(StorageObjectStorageQueue.cpp:442). The test reached 25.8 via a robot cherry-pick of #108977, a
pr-critical-bugfix, leaving that branch a ~50%-blind regression test for a crash. Could a maintainer
add v25.8-must-backport so the existing automation replays it?

Validation. A plain run is vacuous half the time, so the draw was forced (2x2 below): pre-fix FAILs
in 315 s with the CI text verbatim, post-fix passes, and the winning-draw arm is the control showing
the probe discriminates. Reverting the src/ guard from #108977 makes the repaired test fail with the
abort, not the timeout. Unforced, 50/50 green on both branches.

Measurement detail

2x2 on 25.8 (released v25.8.29.51-lts, buildId c345ea4f094c8b6876f0e8beefbc0beb452a3389):

arm pre-fix post-fix
draw forced True (losing) FAIL 315.20 s, 0 did not match expectations in 120 retries PASS 153.18 s
draw forced False (winning) PASS 159.00 s (control) PASS 135.44 s

CI's own failing job took 315.69 s. Server-log confirmation, pre-fix vs post-fix: DDL
use_persistent_processing_nodes = true vs = 0; engine path .../persistent_processing/<node> vs
.../processing/<node>; Failed to set files as processing 0 for the table under test vs 1 naming it. A
sibling test in this module increments the same server-lifetime counter, so that line is attributed
by table name.

Unforced, randomizer live: 25.8 post-fix 50/50 PASS, with 50 distinct tables, 50 failpoint fires
and a processing-path histogram of 1118 /processing/ to 0 /persistent_processing/. 25.8 pre-fix
over 20 runs: 7 of 20 red on the target signature, the other 4 failures being host network noise,
consistent with the 42.9% FAIL rate in CI. master post-fix 50/50 PASS. Whole-file arms on both
branches, compared as sets of failure reasons: 0 only-in-fix failures.

On master the setting is still accepted and still readable at runtime, since ALTER MODIFY SETTING
reaches ObjectStorageQueueMetadata::updateSettings. The inertness above is specifically about the
CREATE-time value and the directory literal, not about the setting being ignored.

…ion test

test_batch_set_processing_failure_does_not_crash is red about half the time on
the 25.8 branch: over the 60 days to 2026-08-06 08:00 UTC, 15 FAIL / 20 OK
there, across five failing PRs (four robot backports and one of mine) and six
branch-side runs. master is 0 FAIL over thousands of OK runs, and every 26.x
branch is zero.

The test plants an artificial Keeper conflict node at the hard-coded path
<keeper_path>/processing/<node> so that the engine's keeper multi fails and
ObjectStorageQueueFailedToBatchSetProcessing increments; it then waits for that
counter to rise. On 25.8 the processing directory is not a fixed name: it is
selected at runtime from the use_persistent_processing_nodes table setting, via
ObjectStorageQueueUnorderedFileMetadata.cpp:32 ->
ObjectStorageQueueIFileMetadata.cpp:203-205. The shared test helper randomizes
that setting (helpers/s3_queue_common.py:172, which is :125 on 25.8), and the
test never pins it, so half the time the engine uses persistent_processing. The
planted node is then inert, the multi succeeds, and the counter can never move,
so the wait runs out its 120 retries.

Pin use_persistent_processing_nodes = 0 in the test's own additional_settings,
next to the list_objects_batch_size pin that is already there for the same class
of hazard: a fixture silently depending on an engine or helper default.
settings.update(additional_settings) runs after the draw, so the test's value
wins. test_5.py pins this same setting where its assertions depend on it.

This also lands on master, where the CREATE-time value of the setting is never
consumed: the unordered processing directory is the compile-time literal
"processing" (ObjectStorageQueueUnorderedFileMetadata.cpp:27) and the metadata
constructor is passed a literal true (StorageObjectStorageQueue.cpp:442), so the
added line is inert there. Master does run a background cleanup over
zookeeper_path / "processing" (ObjectStorageQueueMetadata.cpp:1490) and that
cleanup is enabled for this table, but it removes only nodes older than
persistent_processing_node_ttl_seconds, six hours by default and not set by this
test, whereas the planted node is removed as soon as the test's 120-retry wait
completes, about two minutes at most. Neither of the two conditions that enable
that cleanup is the pinned setting: they are the same literal true and the TTL,
so this holds with or without the added line. Being inert on master is what lets
one commit be correct on both trees, and it matters because the test reached
25.8 through a robot cherry-pick of ClickHouse#108977, a pr-critical-bugfix, leaving that
branch with a roughly 50%-blind regression test for a crash.

No assertion is weakened and no no-random-* tag is added: this suite's other 95
unpinned create_table sites keep the draw live.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai

groeneai commented Aug 6, 2026

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

Three independent review rounds on this change, plus a second-model gate pass per round. The +3/-0
test-setting pin survived all three cold code reviews unchanged; everything that bounced was published
prose, corrected before this PR was opened.

Round 3

✅ Clean, no findings - the third cold review and its gate pass both returned nothing, and round 2's
correction was re-verified from source rather than taken on trust. Re-derived independently this round:
the cleanup conjunction step by step (both operands, the six-hour TTL default, the scheduling condition,
the only earlier return, and the directory actually scanned), confirming round 2's reading and that the
committed wording now matches it. Also re-derived: the failure-rate figures at their named clock, the AST
census, every count in the validation table, and all eight source citations against the branch each is
scoped to, each with a negative control. Test liveness was traced rather than assumed - deleting the
three added lines reproduces the pre-fix file byte for byte, and that file is the arm that fails - and the
carrier set was enumerated before reading the plan's own list, matching it exactly.

Round 2

⚠️ The commit message described master's processing-node cleanup gate backwards. An earlier draft
argued the pin was safe on master because cleanupPersistentProcessingNodes "is gated on
cleanup_processing_files ... so the pin cannot switch it on". That gate is in fact open:
cleanup_processing_files is use_persistent_processing_nodes_ && persistent_processing_node_ttl_seconds,
StorageObjectStorageQueue.cpp:442 passes a literal true, and the TTL defaults to six hours, so the
cleanup does run and does scan zookeeper_path / "processing" - the directory this test plants its
conflict node in. Fixed: the message now gives the real reason, which is the TTL - the cleanup only
removes nodes older than six hours, and this test creates and deletes its node within a couple of
minutes. That holds with or without the added line, since the constructor argument is a literal either
way, so it is a pre-existing property and no behaviour changes. Both cited lines existed, so a citation
check passed it; only evaluating the conjunction caught it.

💡 Provenance recorded with a do-not-reinstate note: the claim came from the previous round's own fix
plan, where it was labelled "verified" on the strength of the lines existing.

Round 1

⚠️ A count reproducible under no predicate. "62 other create_table call sites" matched nothing at
any ref. An AST census gives 101 total / 6 pinned / 95 unpinned on this branch (96 on master, 56 on
25.8). Corrected, with "unpinned" stated explicitly.

⚠️ "The setting is deprecated and its value is ignored" on master. Refutable in one grep:
ObjectStorageQueueMetadata::updateSettings reads it on ALTER, it is in both changeable-settings
lists, the member is a mutable std::atomic<bool>, and it still has a live behavioural read in the
ordered-mode path. The wording has upstream precedent in an open PR, but it is the sentence a reader
checks first. Narrowed to what is exactly true and is all this change needs: the CREATE-time value
is never consumed, because the processing directory is the compile-time literal "processing" and the
metadata constructor receives a literal true.

❌ Gate finding "the pin is not proven to take effect" - disagreed, with evidence. The premise was
right that no assertion checks the setting, but the conclusion fails at a necessary step: the test waits
on ObjectStorageQueueFailedToBatchSetProcessing, which has exactly one increment site in 25.8
(ObjectStorageQueueSource.cpp:271, the failure branch of the tryMulti), and the only planted
collision is the node in /processing. A satisfied wait is therefore itself a runtime proof that the
override applied; if it silently stopped applying, the outcome is not a quiet pass but exactly the 315 s
timeout this change removes. The suggested remedy was also measurably wrong for a PR targeting master,
where system.s3_queue_settings reports true for a table created with 0, so an introspection
assertion pinned to 0 would fail there.

💡 Nits, all fixed: the failure-rate figures are correct at their own clock but rolling, so the message
now names the as-of time; "five backport PRs" was imprecise (four robot backports and one of mine); a
helper line number that resolves only on 25.8; and a claim about an "Azure sibling suite" that does not
exist at any ref - AzureQueue is exercised inside this suite, and none of the three files naming it
plants a processing/ node.

Deliberately not changed

  • A surviving mutant, reported not fixed. Disabling the failpoint does not redden the test, because
    the failpoint gates the compaction condition while the wait keys on the counter from the conflict-node
    condition. Verified pre-existing against the unpinned base file, so it is a separate concern and out of
    scope here.
  • No no-random-* tag, no raised retries, no changed list_objects_batch_size. Raising retries
    would have converted a red test into a vacuous green and retired the coverage for a
    pr-critical-bugfix crash.
  • The 25.8 ordered-mode path shares the runtime-selected directory, but this table is unordered;
    flagged, not a carrier here.

Session id: cron:clickhouse-review-slot-11:20260806-210800

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A plain run is vacuous about half the time, so the draw is forced: rewriting the randomizer (helpers/s3_queue_common.py:172, which is :125 on 25.8) to use_persistent_processing_nodes = True makes the pre-fix test FAIL every time, in 315.20 s, with the CI text verbatim (0 did not match expectations in 120 retries). CI's own failing job took 315.69 s.
b Root cause explained? Yes. The test plants a Keeper conflict node at the hard-coded {keeper_path}/processing/{node} so tryMulti fails and ObjectStorageQueueFailedToBatchSetProcessing increments. On 25.8 that directory is selected at runtime from use_persistent_processing_nodes (ObjectStorageQueueUnorderedFileMetadata.cpp:32 -> ObjectStorageQueueIFileMetadata.cpp:203-205), which the shared helper randomizes. On the losing draw the engine uses persistent_processing, the planted node is inert, the multi returns ZOK, and the wait can never be satisfied.
c Fix matches root cause? Yes: it takes control of the input that selects the directory. Not a band-aid. No widened bound, no no-random-* tag, no reduced dataset, and specifically not a raised retries, which would have converted a red test into a vacuous green and retired the coverage for a pr-critical-bugfix crash.
d Test intent preserved / new tests added? Preserved, and proven rather than asserted: with the src/ guard from #108977 reverted, the repaired test fails with the server abort in FileIterator::next (Received signal 6, crash-banner build id matching the mutant binary), and the timeout message appears 0 times. No assertion was weakened and the oracle is untouched. No new test is owed: the deliverable is the repair of an existing regression test.
e Both directions demonstrated? Yes, as a 2x2 on 25.8. Losing draw: pre-fix FAIL 315.20 s, post-fix PASS 153.18 s. Winning draw: pre-fix PASS 159.00 s (the control showing the probe discriminates), post-fix PASS 135.44 s. Server-log confirmation per arm: DDL = true vs = 0, engine path .../persistent_processing/<node> vs .../processing/<node>, and Failed to set files as processing 0 for the table under test vs 1 naming it.
f Fix is general across code paths? Checked by enumerating every hard-coded processing/ reference under tests/integration/test_storage_s3_queue/: 6 lines on master, in exactly two files. This is the only test that plants a node there without controlling the setting. The other is test_persistent_processing_nodes_cleanup in test_5.py (def :1353, node at :1377), which pins the setting to 1 at :1369 (:1226/:1269/:1335 on 25.8, where it also writes to both directories deliberately), so it is not a second instance. On 25.8 test_4.py parameterises the setting and asserts on reported settings, never a Keeper path; on master that file does not reference it at all (0 occurrences, against 2 for persistent_processing_node_ttl_seconds, so the grep discriminates). The 25.8 ordered-mode path shares the runtime-selected directory (ObjectStorageQueueOrderedFileMetadata.cpp:131) but this table is mode='unordered', so it is not a carrier here; flagged, out of scope. AzureQueue has no separate suite: it is exercised inside this one, in the three files that name it (test_0.py, test_6.py, test_system_stop.py), and none of them plants a processing/ node.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for datatypes (test-setting fix, no code path over values). The relevant input axis is the setting itself, and both draws were exercised: arms A and B above. Arm B post-fix is also the empirical check that the Ephemeral rather than Persistent CreateMode implied by pinning 0 is harmless, since ZooKeeper create fails ZNODEEXISTS on path existence alone, independent of mode.
h Backward compatible? Yes. No src/ change, no setting default moved, no serialization format touched, so no SettingsChangesHistory.cpp entry is owed. The DDL is accepted on both branches: on master the value is stored (SHOW CREATE TABLE echoes 0) while system.s3_queue_settings reports true and the engine still uses /processing, which is the measurement showing the line is inert there. A bogus queue setting gives Code: 115 UNKNOWN_SETTING, so that probe discriminates.
i Invariants and contracts preserved? Yes. No engine invariant is touched. The test's own invariant, that the planted conflict node sits in the directory the engine uses, is now guaranteed instead of left to a coin flip. Pinning 0 moves 25.8 onto its own declared default (ObjectStorageQueueSettings.cpp:41 is false), not onto an exotic path. Build ID is unchanged byte-exactly across the whole round (80a7d8ba06222a726ac65e2b77d8f00e875adfa4), which for a test-only diff is the correct assertion and the cheap proof no src/ line was left edited.

Session id: cron:clickhouse-review-slot-11:20260806-210800

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @kssenii, could you review this? On 25.8 the processing-node directory is selected at runtime from use_persistent_processing_nodes, which the shared test helper randomizes, so this test plants its Keeper conflict node in the wrong directory about half the time and times out; pinning the setting makes it deterministic. Since the test only guards the out-of-bounds abort on 25.8, where it arrived via the robot cherry-pick of #108977, could you also add v25.8-must-backport so the existing automation replays this there?

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai if the test is flaky on 25.8, why are you merging the fix to master?

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Because I do not open release-branch PRs by hand. The route I follow is a master PR plus a vX.Y-must-backport label, and the label is a maintainer call.

The pin is inert on master: there the processing directory is the compile-time literal zk_path / "processing" (ObjectStorageQueueUnorderedFileMetadata.cpp:27) and the metadata constructor gets a literal true (StorageObjectStorageQueue.cpp:442), so the CREATE-time value is never consumed. 25.8 is the only branch that picks that directory at runtime (getProcessingNodesPath is in 5 files there, 0 on master and on every 26.x line), which is why only 25.8 is red: 16 FAIL / 22 OK in the 60 days to now, against 0 FAIL / 9442 OK on master and 0 on 26.7, 26.6, 26.5 and 26.3. The 15 / 20 in the description was the same query a day earlier.

So the same commit is correct on both trees, and the 25.8 delivery is the label. Could you add v25.8-must-backport? Per tests/ci/cherry_pick_branches.py that selects 26.7, 26.6, 26.5, 26.3 and 25.8; the test is unpinned on all five, the pin is inert on the 26.x lines for the reason above, and I checked the cherry-pick applies onto 25.8 with no conflict.

@PedroTadim PedroTadim self-assigned this Aug 7, 2026
@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 7, 2026
@clickhouse-gh clickhouse-gh Bot closed this Aug 7, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5e4a6ce]

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 7, 2026
@PedroTadim PedroTadim closed this Aug 7, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@groeneai dont be concerned about the 25.8 branch for now

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Understood, dropping the 25.8 work. Withdrawing the v25.8-must-backport ask; @kssenii, no review needed here either.

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 groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants