Skip to content

Add ReadBufferFromS3RequestsCut profile event and stop 04812 from counting cut requests - #124701

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04812-s3-requests-cut-profile-event
Oct 9, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04812-s3-requests-cut-profile-event

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115050 (comment)
Related: #119730

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added profile event ReadBufferFromS3RequestsCut: the number of requests to S3 disks cut to one buffer fill because the connection group of the disks was at or above disk_connections_soft_limit.

Description

04812_prewhere_fragmented_ranges_s3_read_requests asserts S3ReadRequestsCount < 20. It failed in Stateless tests (arm_asan_ubsan, azure, parallel) on #115050 and #123894: 1723-1843 GETs instead of 2-6 for the same bytes, 0 errors, and every rerun passed.

Cause. Since #119730, ReadBufferFromS3::initialize cuts each request to one buffer fill while the server-wide Disk connection group is at or above disk_connections_soft_limit (5000). In the azure job every MergeTree table is on the azure disk, which shares that group with s3_disk, and the job's metric_log shows the group at 5600-6000 connections for 10-15 s around both failing queries. So the count depends on other queries, and nothing showed that a request was cut.

Change. A new profile event ReadBufferFromS3RequestsCut, incremented where a request is cut, and the test bound becomes S3ReadRequestsCount < 20 + ReadBufferFromS3RequestsCut. Requests that are not cut must still stay below 20, so the test keeps its power. The .reference is unchanged.

Validation (debug build, s3_disk on a local MinIO):

  • disk_connections_soft_limit = 1: the unmodified test fails 5/5 with the CI diff (about 1700 requests, all but 7 and 3 of them cut); the fixed test passes 50/50.
  • Default limit: the fixed test passes 50/50, the counter is 0 and the request counts equal master's.
  • A read bound per fragmented range (the regression the test guards) fails the fixed test with both limits; removing only the new increment fails it under the soft limit.

🤖 Generated with Claude Code


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

Version info

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

…nting cut requests

Since ClickHouse#119730, `ReadBufferFromS3::initialize` cuts every request of an S3
disk to one buffer fill while the process-wide `Disk` connection group holds
at least `disk_connections_soft_limit` connections. Whether a request is cut
therefore depends on the rest of the server, and nothing recorded that it
happened.

`04812_prewhere_fragmented_ranges_s3_read_requests` asserts
`S3ReadRequestsCount < 20`. In `Stateless tests (arm_asan_ubsan, azure,
parallel)` every MergeTree table lives on the `azure` disk, which shares the
`Disk` group with `s3_disk`; bursts of Azure disk reads held the group at
5600-6000 connections for 10-15 s, and both failing runs (PR 115050 and
PR 123894) fell inside such a window: 1723-1843 GETs instead of 2-6 for the
same bytes, with 0 errors.

The new event is incremented exactly where `cut_request_end` is set, and the
test now bounds only the requests that were not cut:
`S3ReadRequestsCount < 20 + ReadBufferFromS3RequestsCut`. Under the cut, the
uncut requests are the ones the test is about (one per requested range), so a
read bound that advances per fragment still fails the test, with and without
the soft limit. Without pressure the event is 0 and the assertion is
unchanged.

Validated with `disk_connections_soft_limit = 1` on a local server: the old
test fails 5/5 with the CI diff, the new one passes 50/50; with the default
limit the new test passes 50/50 with the same request counts as before.

Related: ClickHouse#115050 (comment)
Related: ClickHouse#119730

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 8, 2026
@groeneai

groeneai commented Oct 8, 2026

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) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 ⚠️ No committed test forces the soft limit, so deleting the new increment leaves CI green (04812...sh:88,100) DISAGREE Asserting a profile event value in test_s3_disk_connections_soft_limit is integration-test trivia per .claude/CLAUDE.md. Verified locally: with disk_connections_soft_limit = 1 and the increment removed, the test fails 5/5; with it, requests - cut equals the unpressured counts (7 and 3). I can add that assertion if wanted.
2 💡 Event not added to the Keeper event list (KeeperConstants.cpp) DISAGREE Keeper's S3 client is not a disk client (KeeperSnapshotManagerS3.cpp:125, for_disk_s3 = false), so the cut never runs there.

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

Session id: cron:clickhouse-review-slot-9:20261008-174300

@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A server with disk_connections_soft_limit = 1 makes the unmodified test fail 5/5 with the CI diff (1 -> 0, 1 1 -> 1 0).
b Root cause explained? Yes. Since #119730 every S3 disk request is cut to one buffer fill while the server-wide Disk connection group is at or above the soft limit. In the azure job the azure disk shares that group with s3_disk, and metric_log shows it above 5000 around both failing queries, so the query made ~1800 requests for the same bytes.
c Fix matches root cause? Yes. The cut is server-wide by design and cannot be pinned per query; the new ReadBufferFromS3RequestsCut counter records it where it happens, and the test bounds only the requests that were not cut (still < 20).
d Test intent preserved / new tests added? Yes. A per-range read bound (the regression the test guards) still fails both lines, with and without the soft limit; .reference unchanged; without pressure the assertion is the same as before.
e Both directions demonstrated? Yes. Soft limit 1: unmodified test 5/5 FAIL, fixed test 50/50 OK; removing only the new increment: 5/5 FAIL. Default limit: fixed test 50/50 OK.
f Fix is general across code paths? Yes. ReadBufferFromS3::initialize is the only place that cuts a request; readBigAt never cuts, and Azure/HDFS/web read buffers have no cut path.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for types (no data path change). Both test paths (index analysis, refiner) and both limit states, including the state flipping during a query, were run.
h Backward compatible? (maintainer-approved exception only) Yes. Adds a profile event only; no setting, format or behaviour change.
i Invariants and contracts preserved? Yes. The increment sits inside the existing cut branch and changes no control flow; it runs on the thread that sends the request, so it is attributed to the same query as S3GetObject.

Session id: cron:clickhouse-impl-slot-7:20261008-164800

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [743e625]

Summary: ✅


AI Review

Summary

This PR adds ReadBufferFromS3RequestsCut to count S3-disk requests that are intentionally cut when the shared disks connection group is at or above disk_connections_soft_limit, and updates 04812_prewhere_fragmented_ranges_s3_read_requests.sh to discount those pressure-induced requests. I reviewed the current diff together with the prior PR discussion and did not find an unresolved correctness, safety, or coverage issue in the change: the new counter is incremented in the exact branch that truncates the request, and the adjusted stateless assertions still preserve the test's ability to catch the original fragmented-range regression rather than failing on unrelated server-wide connection pressure.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 743e625.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.10% 92.20% +0.10%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 10/10 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 8, 2026
@groeneai
groeneai requested review from CheSema and kssenii October 8, 2026 18:22
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. label Oct 8, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 9, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 9, 2026
Merged via the queue into ClickHouse:master with commit 35cab67 Oct 9, 2026
152 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 9, 2026
filimonov pushed a commit to Altinity/ClickHouse that referenced this pull request Nov 21, 2026
… event and stop 04812 from counting cut requests

Counts the S3 disk reads cut to one buffer fill by ClickHouse#119730, so the cut is visible in
`system.events` and `query_log`. `04812_prewhere_fragmented_ranges_s3_read_requests` asserts
a request count and fails when the server is above the soft limit; it now excludes cut requests.

Upstream: ClickHouse#124701
Upstream merge commit: 35cab67
Commits of the upstream pull request:
- 743e625 Add ReadBufferFromS3RequestsCut profile event and stop 04812 from counting cut requests

Adaptation for antalya-26.8:
- None: applied as is.

(cherry picked from commit 35cab67)

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
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. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-improvement Pull request with some product improvements 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