Skip to content

Convert part_loading_tree_rollback tests from stateless to integration - #112000

Merged
alexey-milovidov merged 8 commits into
ClickHouse:masterfrom
groeneai:convert-plt-rollback-tests-to-integration
Jul 31, 2026
Merged

alexey-milovidov merged 8 commits into
ClickHouse:masterfrom
groeneai:convert-plt-rollback-tests-to-integration

Conversation

@groeneai

@groeneai groeneai commented Jul 27, 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

Related: #111053
Related: #111922

First PR of the conversion series requested in
#111922 (comment): functional tests must
not fabricate or manually intervene with data parts outside the ClickHouse API surface. I enumerated
the 25 violating stateless tests and proposed converting them one integration module per mechanism
in #111922 (comment), which was approved
in #111922 (comment). This PR converts
the first group, the five part_loading_tree_rollback tests.

A stateless test that writes a plaintext file into a part directory silently assumes the part lives
on a local default disk. On an object-storage disk every file inside a part directory must be in
DiskObjectStorageMetadata format, so a raw plaintext txn_version.txt cannot deserialize and part
loading fails with CORRUPTED_DATA; the cleanup path derived its target from the default disk and
so leaked the poisoned part, breaking every later server start. That assumption cannot be expressed
in a stateless test, because the harness owns and randomizes the disk configuration. An integration
test owns its own server and disk configuration, so the assumption becomes explicit and enforced by
construction rather than by a skip tag.

New tests/integration/test_part_loading_tree_rollback/, one instance, four tests, +339 lines,
replacing 767 lines of shell and their 8 reference lines:

new test replaces PartLoadingTree::add behavior under test
test_reparent 04063_part_loading_tree_rollback_reparent intersection arm: children of an evicted rolled-back node are re-inserted, not dropped
test_contains 04241_part_loading_tree_rollback_contains containment arm: committed descendants of a rolled-back ancestor are promoted once the ancestor is demoted to Outdated
test_evict_reinsert_contains 04417_part_loading_tree_rollback_evict_reinsert_contains intersection arm with a nested committed subtree: every orphan of the evicted node survives, the container active and the part it contains covered by it rather than dropped
test_tmp_metadata 04500_part_loading_tree_rollback_tmp_metadata a lone txn_version.txt.tmp means the creating transaction never committed

Coverage is moved, not reduced: each scenario keeps its fabricated part lattice and its transaction
metadata payload byte for byte, and the assertions are strengthened from per-part active counts to
whole-active-set equality for three scenarios, plus an explicit active/inactive presence map for
test_evict_reinsert_contains, which is the one case where a regression could drop an orphan
instead of covering it and stay invisible to an active-only check. All four intended code paths are still exercised, which I verified by
mutation: breaking each scenario's fabrication produces exactly the failure that scenario exists to
catch, and the failures differ per scenario. test_contains is the interesting one - the
containment arm never consults the transaction status, so its mutation lets ATTACH succeed and
only the active-set assertion catches the regression.

04624_part_loading_tree_rollback_startup_recovery is deleted without a replacement. Its subject
was the stateless-only DETACH TABLE ... PERMANENTLY cleanup helper: recovering a leaked
permanently-detached table whose name still blocks CREATE. That machinery only existed to survive
a stress-test server restart landing mid-script, and an integration test owns its server, so the
subject ceases to exist. Its reference output was three catalog counts plus OK; nothing in it
reached PartLoadingTree::add.

This removes the Stress-suite failures, which run the master tree's test files. It does not affect
the Upgrade check column: tests/docker_scripts/upgrade_runner.sh clones the previous release tag
and runs clickhouse-test --queries=previous_release_repository/tests/queries, so the old scripts
stay active there until the next release rollover, or until #111772 makes the existing
no-object-storage skip tags fire.

Two open PRs touch the same five stateless files, so ordering matters. #111922 pins them to the
local default storage policy as a stopgap and is already approved, so it should merge first; this PR
then removes them outright, so once it lands I will merge master in and resolve the five
modify/delete conflicts in favour of the deletion. Until then GitHub reports this PR as
conflicting. #111968 deletes the same ten
files with no replacement; if it merges first the deletions here become no-ops and only the new
integration module remains, which I verified resolves cleanly either way. Whichever lands first, the
part of this PR that matters is the module that keeps the four PartLoadingTree::add scenarios under
test.

The remaining violators from the enumeration are grouped into follow-up PRs by mechanism, in the
order given in the approved plan: the txn_version group next, then the rest.

Test run: pytest test_part_loading_tree_rollback/test.py -> 4 passed; --count 10 -> 40 passed.

Version info

  • Merged into: 26.8.1.517 (included in 26.8 and later)

groeneai and others added 6 commits July 26, 2026 19:56
Functional tests must not fabricate or manually intervene with data parts
outside what the ClickHouse API surface exposes. A stateless test that writes a
plaintext file into a part directory silently assumes the part lives on a local
default disk: on an object-storage disk every file inside a part directory must
be in DiskObjectStorageMetadata format, so a raw plaintext txn_version.txt
cannot deserialize, part loading fails with CORRUPTED_DATA and the server does
not start. The cleanup path derived its target from the default disk, so on an
object-storage policy it also missed the real data path and leaked the poisoned
part, breaking every later start. That assumption cannot be expressed in a
stateless test because the harness owns and randomizes the disk configuration,
and the no-object-storage skip tags were inert because the harness did not
forward the matching flag. An integration test owns its own server and disk
configuration, so the assumption becomes explicit and enforced by construction.

The four PartLoadingTree::add rollback scenarios move into one module with their
fabricated part lattices and transaction-metadata payloads preserved byte for
byte, and their assertions strengthened from per-part active counts to
whole-active-set equality. Each scenario's liveness was verified by mutation:
breaking its fabrication produces exactly the failure that scenario exists to
catch, and the outcomes differ per scenario - the containment arm never consults
the transaction status, so its mutation lets ATTACH succeed and only the
active-set assertion catches the regression.

04624_part_loading_tree_rollback_startup_recovery is deleted without a
replacement. Its subject was the stateless-only DETACH TABLE ... PERMANENTLY
cleanup helper, machinery that only existed to survive a stress-test server
restart landing mid-script; an integration test owns its server, so the subject
ceases to exist. Nothing in it reached PartLoadingTree::add.

This removes the Stress-suite failures, which run the master tree's test files.
It does not affect the Upgrade check, which clones the previous release tag and
runs its frozen test files.

Related: ClickHouse#111053
Related: ClickHouse#111922
…ctive

Review fix round r1 on the part_loading_tree_rollback conversion.

test_evict_reinsert_contains asserted only the active part set, so a regression
that dropped the orphan all_2_3_1_0 instead of covering it with the reinserted
container all_2_4_2_0 passed identically. It now asserts the full name-to-active
map after SYSTEM WAIT LOADING PARTS, which Outdated parts require because they
load asynchronously. A mutation expecting the orphan absent rather than inactive
fails, so the new dimension is live.

Its docstring claimed the test pins the (level, mutation) descending sort in
evict_and_reinsert. It does not: collect walks children, a std::map keyed on
MergeTreePartInfo, so the container 2-4 is already emitted before the part 2-3
it contains, and the incoming 5-6 is disjoint from both. Removing the sort
leaves the outcome unchanged. The docstring now says so explicitly, and notes
that all_2_3_1_0 and all_5_6_1_0 share (level, mutation) = (1, 0) while build
uses a non-stable std::sort, so their relative order is unspecified and the
asserted outcome holds either way.

The module-scope SYSTEM STOP MERGES was inert. startStopAction with no table
locks only the tables that exist at that moment, keyed per IStorage, and the
fixture ran before any CREATE TABLE; the lock also does not survive the
DETACH/ATTACH cycle that destroys the storage instance. Merges are now stopped
per table after CREATE and again after each ATTACH.

Co-Authored-By: Claude Fable 5 <[email protected]>
A background merge would rewrite the part set these tests assert on. Issuing
SYSTEM STOP MERGES after ATTACH TABLE cannot prevent that: ATTACH runs
IStorage::startup() before it returns, and StorageMergeTree::startup schedules
the background assignee immediately, so a merge can be selected before the
next statement reaches the server. The fabricated parts are byte-identical
clones of one small part, so they are structurally mergeable and the window is
narrow rather than closed.

Setting max_bytes_to_merge_at_max_space_in_pool = 0 in the table metadata makes
the storage come up with merging already off on every startup, including the one
inside ATTACH. It is enforced before any merge selector runs:
getMaxSourcePartsBytesForMerge returns 0 and the merge selection short-circuits
with "Current value of max_source_parts_bytes is zero". The per-table
SYSTEM STOP MERGES is kept as a redundant second line and its docstring no
longer claims to close the startup window.
…nction references

Two docstrings presented a tied (level, mutation) pair as a determined sequence.
PartLoadingTree::build sorts with a non-stable std::sort keyed only on
(level, mutation), so in test_contains the pair all_1_2_1_0 / all_3_4_1_0 (both
(1, 0)) and in test_tmp_metadata the pair all_2_3_0_0 / all_1_1_0 (both (0, 0))
may be inserted in either order. Simulating PartLoadingTree::add over both
permutations gives the same active set in both tests, so the assertions are
correct as written and unchanged; only the descriptions were over-precise.
test_reparent gets no such note - its parts have a strict total order under the
sort key, so a tie disclaimer there would be false.

Also write prose references to functions as f rather than f(), per AGENTS.md.

No executable code changed: the module's AST with docstrings stripped is
byte-identical to the previous commit.
…nous

The helper detaches the table so its part directory can be edited, and every
test re-attaches it afterwards. Without SYNC the detach returns while the
storage instance is still tracked in DatabaseAtomic::detached_tables, so a
concurrent StoragePtr holder makes the later ATTACH throw TABLE_ALREADY_EXISTS
instead of waiting. ServerAsynchronousMetrics is such a holder: it iterates a
snapshot of the database's tables on its own timer, which is exactly the case
InterpreterCreateQuery warns about. SYSTEM WAIT LOADING PARTS and the
filesystem work in between only narrow that window.

SYNC is per statement, so nothing else in the module changes semantics, unlike
setting database_atomic_wait_for_drop_and_detach_synchronously.

No assertion, fixture or part lattice changed: the module's AST with docstrings
stripped differs from the previous commit only by the added SYNC token.

Co-Authored-By: Claude Fable 5 <[email protected]>
…e in inline code

AGENTS.md asks for literal names from ClickHouse SQL, classes and functions, and
literal log-message excerpts to be wrapped in inline code blocks. The module already
did that nearly everywhere; five lines were left bare. The quoted log excerpt in
create_table_with_one_part moves from double quotes to backticks rather than carrying
both.

The bare part names in the numbered insertion-order tables stay bare on purpose:
backticks would break the column alignment those tables rely on, and flowing prose
already backticks part names.

Docstrings and comments only. With docstrings stripped, the module's AST is
byte-identical to the previous commit, so the mutation matrix and the DETACH SYNC
liveness proof carry over unchanged.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (6 rounds, 0 open blockers)

Before opening this PR I ran an independent review lane over it: a cold code review by a
reviewer that never sees the implementer's own evidence, plus an adversarial second-model gate
on every commit. Six fix rounds. The final round returned 0 findings on the published content.
Recorded here so a reviewer can see what was already challenged and how, and skip re-deriving it.

⚠️ Findings that changed the PR

# Finding Resolution
1 The merge guard was a SYSTEM STOP MERGES statement issued after ATTACH, which cannot cover the merge window inside ATTACH itself: ATTACH runs IStorage::startup before returning and StorageMergeTree::startup schedules the background assignee immediately. Moved into the table metadata as max_bytes_to_merge_at_max_space_in_pool = 0, so merging is off on every startup including the one ATTACH performs. Checked at StorageMergeTree::selectPartsToMerge ahead of both selection lambdas; the statement is kept only as a redundant second line of defence.
2 test_evict_reinsert_contains asserted only the active set, so a regression that dropped the nested orphan all_2_3_1_0 instead of covering it would have been invisible. Assertion strengthened to a whole active/inactive presence map over every loaded part.
3 A docstring claimed the test pins the (level, mutation) descending sort inside evict_and_reinsert. It does not: collect walks a std::map keyed on MergeTreePartInfo, which already yields the container before the part it contains. Claim retracted. Verified by re-implementing PartLoadingTree::add and driving both tie orders through all four lattices: outcomes identical, so this is documentation accuracy, not flakiness, and the assertions correctly stayed untouched.
4 Three lattices contain (level, mutation) ties, and PartLoadingTree::build sorts with a non-stable std::sort, so the documented insertion orders were presented as fixed sequences they are not. Each affected docstring now states the tie and why the asserted outcome holds under either order.
5 The DETACH was asynchronous, so the storage instance could still be tracked in DatabaseAtomic::detached_tables while another subsystem held a StoragePtr, making the later ATTACH throw TABLE_ALREADY_EXISTS instead of waiting. Changed to DETACH TABLE ... SYNC. Liveness proved by counting the Waiting for detached table ... to be no longer in use log line across a --count 10 run: 40 detaches / 0 waits before, 40 / 40 after.
6 Literal SQL, error and log-message names in the module prose were not wrapped in inline code, against the repository instruction in AGENTS.md. All sites wrapped. The module's AST with docstrings stripped is byte-identical to the previous commit, so no test evidence needed re-running.
7 The description credited the conversion request to the wrong comment - it cited my own enumeration comment rather than the request it answered, and never recorded that the plan was approved. Description now cites the request, the plan and its approval separately.

💡 Noted, not blocking

  • The symmetric next/isDisjoint branch of PartLoadingTree::add, and the
    Unreadable/CORRUPTED_DATA and UnknownCSN outcomes of read_txn_status, have no test
    targeting them directly. Both gaps predate this module and are recorded in a trailing comment
    rather than silently carried.
  • 04624_part_loading_tree_rollback_startup_recovery is deleted with no replacement because its
    subject was the stateless harness's own cleanup helper, not engine behavior. Nothing in it
    reached PartLoadingTree::add.

Session id: cron:clickhouse-review-slot-10:20260727-010500

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The deliverable is the test itself, so the repro is the test command: pytest test_part_loading_tree_rollback/test.py -> 4 passed (21s). Each scenario's negative direction is deterministic too: six mutations, six predicted failures, all on the first attempt.
b Root cause explained? Yes. A stateless test writing a plaintext file into a part directory assumes the part is on a local default disk. On an object-storage disk every file in a part directory must be DiskObjectStorageMetadata, so the plaintext txn_version.txt fails to deserialize (CORRUPTED_DATA) at part load, the table load fails and the server does not start; the cleanup path derived its target from the default disk, so it also leaked the poisoned part and broke later starts. In a stateless test that assumption cannot be stated - the harness owns and randomizes the disk configuration, and the no-object-storage tags were inert because the harness did not forward the matching flag.
c Fix matches root cause? Yes. It is a layer change, not a band-aid: an integration test owns its server and disk configuration, so the assumption is explicit and enforced by construction. No widened bound, no blanket skip tag, no reduced dataset, no defensive check. The band-aid alternative (keep the stateless tests, pin storage_policy = 'default') is #111922, the approved stopgap this supersedes as the durable answer.
d Test intent preserved / new tests added? Yes. Each of the four scenarios keeps its fabricated part lattice and its transaction-metadata payload byte for byte, and assertions are strengthened from per-part active counts to whole-active-set equality, plus an explicit active/inactive presence map in test_evict_reinsert_contains (the one case where a regression could drop an orphan instead of covering it and stay invisible to an active-only check). 04624 is deleted without a replacement because its subject was the stateless-only DETACH ... PERMANENTLY cleanup helper, which the conversion removes; it never reached PartLoadingTree::add (its reference output was three catalog counts plus OK).
e Both directions demonstrated? Yes. Positive: 4 passed, and 40 passed under --count 10. Negative, by mutation: omitting the rolled-back txn_version.txt in test_reparent / test_evict_reinsert_contains, and deleting the .tmp in test_tmp_metadata, each produce the exact Part X intersects previous part Y LOGICAL_ERROR that scenario exists to catch; omitting it in test_contains lets ATTACH succeed (the containment arm never consults the transaction status) and fails the active-set assertion instead; and in test_evict_reinsert_contains both swapping the container/contained active verdicts and expecting the covered orphan to be absent rather than inactive fail. Six mutations, six distinct predicted outcomes, all observed.
f Fix is general across code paths? Yes for what is converted: the four preserved scenarios cover both distinct mechanisms (intersection-arm eviction and containment-arm downstream promotion) and both RolledBack discriminators (on-disk Tx::RolledBackCSN, and the tmp-only layout), plus NoMetadata. The symmetric next/isDisjoint branch and the Unreadable/UnknownCSN outcomes were uncovered before this PR and are uncovered after it - pre-existing gaps, not introduced here, and now named in a code comment so the next reader sees them. Adding that coverage would change what this PR is.
g Fix generalizes across inputs (params/datatypes/wrappers)? Not a value-domain fix, so no type-wrapper matrix applies. The relevant axis is the storage-policy matrix (local / s3 / encrypted / azure), and it is collapsed deliberately: the module pins its own local disk, which is the entire point of the conversion. Cross-disk behavior of the transaction-status read is a source concern, not this test's.
h Backward compatible? N/A - tests only. No settings, no defaults, no SettingsChangesHistory.cpp, no formats, no user-visible behavior.
i Invariants and contracts preserved? Yes. The invariant under test - PartLoadingTree::add classifies a rolled-back part correctly and every orphan of an evicted node survives, either active or covered by an active container - is preserved carrier by carrier. The (level, mutation)-descending re-insertion order inside evict_and_reinsert is deliberately not claimed as covered: collect's walk over the std::map-ordered children already yields a container before the part it contains, so for these lattices that sort is not load-bearing, and the test docstring says so. Test-side: each test function is self-contained (DROP TABLE IF EXISTS ... SYNC first, DROP last), uses a distinct table name, and depends on no other test's state, so the module is order-independent under the module-scoped fixture. fabricate_part asserts from a container listing that the transaction files exist iff requested, and every raw write is read back and compared byte for byte, so a silently no-oping write cannot pass.

Session id: cron:clickhouse-impl-slot-4:20260726-210100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — first PR of the conversion series from the plan you approved: the five part_loading_tree_rollback tests become one integration module, so the fabricated part directories and raw txn_version.txt writes stop assuming a local default disk. Four tests replace the four engine scenarios; 04624 is dropped because its subject was the stateless cleanup helper, not PartLoadingTree::add.

@clickhouse-gh

clickhouse-gh Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [80c2e96]

Summary: ✅


AI Review

Summary

This PR converts the five part_loading_tree_rollback stateless shell tests into one integration module with explicit local-disk setup, and most of the scenario coverage is preserved or strengthened. The remaining problem is that the new helper still leaks a detached table on failure paths, so one real regression can poison later pytest-repeat iterations instead of producing independent reproductions.

Findings

⚠️ Majors

  • [tests/integration/test_part_loading_tree_rollback/test.py:160-170] create_table_with_one_part only does DROP TABLE IF EXISTS on entry and never recovers a table left in system.detached_tables. Once any exception hits after DETACH TABLE ... SYNC (the existing ATTACH TABLE failure path from the open review thread, or an earlier fabricate_part failure), the next --count repetition reuses the same module-scoped cluster, DROP TABLE IF EXISTS becomes a no-op, and the following CREATE TABLE fails with TABLE_ALREADY_EXISTS ... (detached). That turns the first real PartLoadingTree failure into a cascade of setup failures, which is exactly the cleanup path the deleted 04624 test used to protect. Suggested fix: recover detached leftovers at the start of the helper (remove fabricated parts, ATTACH, then DROP), or wrap the detach/reattach window in a try/finally that guarantees cleanup on every exception path.
Final Verdict

Needs changes before merge.

…policy

The converted integration test still inherited whichever storage policy the
server config exposes as the `merge_tree` default, and derived the part
directory from `system.tables.data_paths[1]`. Both are hidden storage-layout
assumptions, the same ones the stateless tests carried.

Measured on a scratch module configured with an object-storage default policy
over minio: without the pin three of the four tests fail with
`Code: 246 ... Cannot parse input: expected '\n' before: 'version: 1 ...
(CORRUPTED_DATA)`, which is the signature the stateless tests produce in the
Stress and Upgrade checks. With the pin all four pass against that same
config.

`arrayElement(data_paths, 1)` names a volume of the storage policy, not the
directory the part is in. Measured on a two-volume policy after
`ALTER TABLE ... MOVE PART ... TO DISK`: `data_paths[1]` is the first volume's
directory while the part lives under the second, so the fabricated siblings
would be created next to no part at all. `system.parts.path` is
`DataPartStorageOnDiskBase::getFullPath` for the one part being cloned, so its
parent is the directory the fabrication has to target. The derivation asserts
that the last path component really is the part name, so a future layout change
fails the test instead of fabricating parts in a parent directory.

Suggested by clickhouse-gh[bot] in review.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112000&sha=latest&name_0=PR

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

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 6548b0b

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
Stress test (amd_debug) / Logical error: Inconsistent KeyCondition behavior (STID: 5182-684a) the debug-only exact-range consistency check in MergeTreeDataSelectExecutor::markRangesFromPKRange. The server log names the participating condition on this run: key condition (useful: true) (relaxed: false): (_CAST(column 0) in ['2', '2']), (column 1 in [2, +Inf)) - i.e. the widening-_CAST atom class, where matchesExactContinuousRange treats a non-monotonic wider-type comparison as an exact continuous range. #109023 (mine, open)
Stateless tests (amd_tsan, s3 storage, sequential, 1/2) / Install ClickHouse praktika infra: configure_log_export -> get_aws_ssm_parameter -> aws: [ERROR]: An error occurred (502) when calling the GetParameters operation (reached max retries: 2): Bad Gateway, exit code 254. Nothing was built or tested differently. a fix task is created (investigating at full effort - fixing-PR link to follow here)
Sync - CH Inc sync (private, not actionable by me)

Neither failure is caused by this PR's diff, which only converts the
part_loading_tree_rollback stateless tests into an integration test. It contains no server
code, so it cannot change primary-key index analysis or reach an AWS SSM endpoint.

Finish Workflow completed successfully at 13:17:33Z; no check is queued or running.

Session id: cron:our-pr-ci-monitor:20260727-143000

Master modified all five stateless part_loading_tree_rollback tests that this
branch deletes, so every conflict is a modify/delete pair. Resolved delete-wins:
the conversion supersedes the master-side change.

The master-side commit is a326008 "Pin part_loading_tree_rollback tests to
the local default storage policy" (ClickHouse#111922), the stopgap that pinned
storage_policy = 'default' so a raw plaintext txn_version.txt would still parse
on jobs whose default policy is object storage. That knowledge is already carried
by the integration module: create_table_with_one_part pins the same setting and
documents why. Nothing from the master side is lost by dropping these files.

Coverage was verified before resolving. Four of the deleted tests map one to one
onto test_reparent, test_contains, test_evict_reinsert_contains and
test_tmp_metadata. The fifth, 04624_part_loading_tree_rollback_startup_recovery,
has no counterpart and needs none: its own header states it regression-tests the
bash cleanup helper shared by the other four, recovering from a table leaked in
the DETACH TABLE ... PERMANENTLY state by a run killed before its EXIT trap. The
integration module uses DETACH TABLE ... SYNC, has no shared shell helper, and
creates and tears down its cluster per module, so that leak cannot survive into a
later run. It also derives the part directory from system.parts.path instead of
reconstructing it from the default disk and the table uuid, which is the very
fragility 04624 existed to guard. No ClickHouse behaviour is covered by 04624
alone.
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 31, 2026
Merged via the queue into ClickHouse:master with commit 5674d9d Jul 31, 2026
178 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 31, 2026
clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request Nov 9, 2026
A transient AWS SSM failure while configuring log export aborted a whole
Stateless sanitizer job before a single test ran, so the lane reported
`failure` having tested nothing and a real regression in it was invisible
for that run.

`configure_log_export` sits in the mandatory command list of the
`Install ClickHouse` result. It calls `create_log_export_config`, whose
`Secret` fetch runs `Shell.get_output(..., strict=True)`, which raises on
any nonzero AWS CLI exit; `Result.from_commands_run` maps the exception to
a failing result, so the step fails and every later stage is skipped.
Three shapes were observed in CI: exit 254 `An error occurred (502) when
calling the GetParameters operation ... Bad Gateway`, exit 255
`Connect timeout on endpoint URL: "https://ssm.us-east-1.amazonaws.com/"`,
and exit 253 `An error occurred (NoCredentials): Unable to locate
credentials.`

Log export is telemetry, and an unconfigured export is already a supported
state: `start_log_exports` guards on `log_export_host`, the start step
already reports a lapse as a workflow warning, and the llvm-coverage
stateless configs skip configuring it outright while running their full
suites. Only the configure step was fatal; that asymmetry is the gap
ClickHouse#98153 already claimed to have closed.

Each of the three fatal call sites now catches the failure, records a
workflow warning and continues, leaving `log_export_host` unset so the
existing supported path takes over. The tolerance returns a truthy value
because `from_commands_run` treats a `False` return as a failed command,
and `ClickHouseService` separately raises when a config hook returns
exactly `False`. `ci/praktika/secret.py` is deliberately untouched, so the
other secret consumers - release, docker, jepsen, cidb, copilot - stay
fatal, as do a missing or empty SSM parameter. The fourth call site,
`clickhouse_proc.py`'s `logs_export_config` `__main__` branch, was already
tolerant and is unchanged. A retry was rejected: `Result` asserts
`retries == 1` for python callables, and a retry would not bound the blast
radius once exhausted.

The new `ci/tests/test_log_export_non_fatal.py` drives the real production
code against a fake `aws` on PATH. It pins that the job survives all three
shapes, that the warning carries the cause, that a non-telemetry consumer
still fails loudly, and that a real failure elsewhere in the same step
still fails it. The call sites are AST-extracted from the job scripts and
executed rather than pattern-matched, so deleting a handler, deleting the
append, or retargeting it to a list no result runs cannot leave the suite
green.

Sightings: ClickHouse#112025 (comment)
and ClickHouse#112000 (comment)
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 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.

4 participants