Skip to content

Count only the INSERT's own S3 requests in test_s3_disk_apply_new_settings - #127679

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-test-s3-disk-apply-new-settings-own-requests
Oct 25, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-test-s3-disk-apply-new-settings-own-requests

Conversation

@groeneai

@groeneai groeneai commented Oct 24, 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):

Fix flaky integration test test_merge_tree_s3/test.py::test_s3_disk_apply_new_settings in the db disk flavour.

Description

test_merge_tree_s3/test.py::test_s3_disk_apply_new_settings started failing on master in Integration tests (amd_asan_ubsan, db disk, 1/8) right after #121431 (2 of 15 master runs since, 0 of 310 before): d7b58a43, f2c1ac3e.

assert (1606 - 1558) == (17 * 3)

The test measures the S3 requests of one INSERT by diffing the server-global S3WriteRequestsCount. In the db disk flavour the database metadata lives on a plain_rewritable S3 disk, which since #121431 rewrites __meta/snapshot.bin from a background task metadata_snapshot_write_delay_ms (1000 ms) after a layout change, such as the test's own CREATE TABLE. When that PUT lands in the first window, it counts 17 (16 data requests + 1 snapshot write), while the multi-part INSERT still takes 48 = 16 * 3. Both failing runs' server logs show exactly one such untagged __meta/snapshot.bin PUT inside the first window.

The test now reads each INSERT's own ProfileEvents['S3WriteRequestsCount'] from system.query_log by query_id, so background S3 traffic is not counted, and checks that the single-part count is positive.

Validation with the CI ASAN binary of d7b58a43: with the snapshot delay raised to 5 s and sleeps that put the PUT inside the window (local-only), the old test fails with the CI signature (409 - 361) == (17 * 3), and the new one passes, reporting 16 for the INSERT while the global counter moved by 17. Removing the SYSTEM RELOAD CONFIG that enables multi-part upload makes the new test fail (16 == 16 * 3). 50/50 runs with the db disk flavour, 10/10 without it; the whole module is unchanged (23 passed, 3 skipped).

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.748-master (included in 26.11 and later)

…tings

The test measured the S3 write requests of one INSERT by diffing the
server-global `S3WriteRequestsCount` in `system.events`. In the `db disk`
flavour the database disk is a `plain_rewritable` S3 disk, which since
ClickHouse#121431 rewrites `__meta/snapshot.bin` from a background task
`metadata_snapshot_write_delay_ms` (1000 ms) after a layout change such as
the test's own CREATE TABLE. That PUT belongs to no query but bumps the
global counter; when it landed in the first window the single-part count
became 17 (16 data requests + 1 snapshot write) while the multi-part
INSERT still took 48 = 16 * 3, failing `48 == 17 * 3` on master
(Integration tests (amd_asan_ubsan, db disk, 1/8), d7b58a4 and f2c1ac3).

Read each INSERT's own `ProfileEvents['S3WriteRequestsCount']` from
`system.query_log` by `query_id` instead, which no background S3 traffic
of the server can reach, and require the single-part count to be positive
so the comparison cannot pass as `0 == 0 * 3`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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; 0 findings) plus my own cold review (2 nits, no blocker or major).

# Sev Finding Verdict Evidence / action
1 💡 Simpler alternative: with_remote_database_disk=False on node, as test_profile_events_s3 does DISAGREE It would drop the db disk coverage of every test in the module that uses node, and the oracle would still see other background S3 writes. Measured in one run: the INSERT's own count is 16 while the global counter moved by 17

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

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. CI ASAN binary of d7b58a43, local-only probe (metadata_snapshot_write_delay_ms=5000 on the database disk, sleeps around the first window): the old test fails with the CI signature assert (409 - 361) == (17 * 3).
b Root cause explained? The test diffs the server-global S3WriteRequestsCount. In the db disk flavour the plain_rewritable database disk writes __meta/snapshot.bin from a background task 1000 ms after a layout change (#121431). When that PUT lands in the first window it counts 17 (16 + 1), the multi-part window stays 48, and 48 != 17 * 3.
c Fix matches root cause? Yes. Each INSERT's own ProfileEvents['S3WriteRequestsCount'] is read from system.query_log by query_id; background writes belong to no query. No bound widened, no sleep, no flavour opt-out.
d Test intent preserved / new tests added? Yes. Same property (multi-part upload = 3x the single-part requests), plus a > 0 guard. Removing the SYSTEM RELOAD CONFIG that enables multi-part upload makes it fail 16 == 16 * 3.
e Both directions demonstrated? Yes. Same forced timing: old test fails, new test passes, and in that run the INSERT counted 16 while the global counter moved by 17.
f Fix is general across code paths? Yes. The only other integration test that diffs a global S3 write counter, test_profile_events_s3, already disables the remote database disk; the two memory tests in this file already use query_log by query_id.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test oracle fix). Both flavours run: db disk 50/50, without it 10/10.
h Backward compatible? (maintainer-approved exception only) Yes. Test-only change.
i Invariants and contracts preserved? Yes. The config restore in finally is unchanged; a missing query_log row raises instead of passing. Whole module unchanged: 23 passed, 3 skipped, before and after.

Session id: cron:clickhouse-impl-slot-4:20261024-022700

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Michicosun, could you review this and add the can be tested label so CI runs? Since #121431 the plain_rewritable database disk of the db disk flavour rewrites __meta/snapshot.bin from a background task, and that PUT sometimes lands in the window where the test diffs the server-global S3WriteRequestsCount; the test now reads each INSERT's own count from system.query_log by query_id.

@clickhouse-gh

clickhouse-gh Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5091dfe]

Summary: ✅


AI Review

Summary

PR #127679 changes test_s3_disk_apply_new_settings to read each INSERT's S3WriteRequestsCount from system.query_log, excluding unrelated background S3 traffic while preserving the multipart upload assertion. No actionable findings at head 5091dfea98d5651a7463853424891b7f8fd63db2. The documented validation includes a deterministic reproduction, a negative control, and repeated runs with and without the remote database disk. Integration tests were not rerun during this review.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 24, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 25, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 25, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 25, 2026
Merged via the queue into ClickHouse:master with commit 7f4a629 Oct 25, 2026
526 of 528 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 Oct 25, 2026
@clickhouse-gh clickhouse-gh Bot added comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. 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-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. 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