Repository navigation
Bound the response wait of the GCP OAuth token request instead of inheriting the caller's request timeout - #115531
Conversation
…request timeout BackupIO_S3 sets requestTimeoutMs to one hour because backup data transfers can legitimately take that long. getTimeoutsFromConfiguration turns that single value into both the send and the receive socket timeout, and PocoHTTPClientGCPOAuth reused that same `timeouts` member for its bearer token round trip. A credential request that should take milliseconds therefore got a one hour socket receive timeout and parked in the TLS response header read, observed in CI as a 695 s BACKUP with read_rows 0 and a `Some queries hung` job failure. The one hour value predates gcp_oauth by years (1365105, 2022-10-12), so nobody chose it for a token mint; the mint inherited it. Bound the credential round trip independently of the data transfer timeouts, at both mint sites: the explicit ADC triple and the metadata service branch. This restores an invariant the sibling credential paths in the same provider chain already hold explicitly, STS AssumeRole at 1 s connect / 10 s request and EC2 IMDS at 50 ms / 1 s; GCP OAuth was the only member without a bound. The cap value and the non-positive handling are taken from the STS precedent, so the 10 s is named once in S3Defines.h and the two STS literals now use it, leaving fewer unnamed constants than before. A timeout already tighter than the cap is kept rather than raised, and data plane requests keep the full hour. Non-positive must map to the cap rather than being left alone: zero means "no limit" to both ConnectionTimeouts::saturate and Poco's socket layer, so a saturate-based clamp would leave a user who set s3_request_timeout_ms = 0 worse off than the bug. Verified: a raw zero receive timeout still blocks past 25 s, while the clamped value fails at 10.0 s. BackupReaderS3 and BackupWriterS3 share one makeS3Client, so RESTORE is covered with BACKUP, as are GCS disks and the s3 table function. Validated against a mock that accepts the request and never responds: the value the call site passed before was still blocked after 40 s, the value it passes now fails at 10.0 s with a timeout. The mock received exactly one request in both arms, so backup_restore_s3_retry_attempts (default 1000) does not multiply the mint, matching S3HeadObject 1 in the reported 695 s dump.
Internal second-model review (1 finding, adjudicated)An independent model reviewed this diff cold against the PR description. One finding, plus three
The claim is correct and I concede it: both shipped gtest arms call
What exists instead is a both-directions measurement at the real seam: with the value the call site So the residual is real and it is future-regression protection, not missing evidence. 💡 Three nits from my own review, all DISAGREE, no change:
Session id: cron:clickhouse-review-slot-11:20260819-223600 |
|
Workflow [PR], commit [3afa3ef] Summary: ✅
AI ReviewSummaryThis PR decouples the GCP OAuth token-mint timeout from the S3 data-plane request timeout by capping send/receive waits at 10 seconds while preserving the caller's connect timeout, and it adds focused coverage for the timeout helper plus the unchanged data-plane budget. I did not find any remaining correctness, contract, or metadata issues in the current code. Final Verdict✅ No findings. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 78/78 (100.00%) · Uncovered code |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20260819-201100 |
|
cc @Michicosun @alesapin, could you review this? |
clang-tidy's google-runtime-int rejects the bare `long` in the two `static_cast`s (Build (arm_tidy), src/IO/S3/Credentials.cpp:1274-1275). The casts exist because Aws::Client::ClientConfiguration declares connectTimeoutMs and requestTimeoutMs as bare `long`, so the caps have to match that field type rather than a fixed-width spelling of our own choosing. Deriving the type with decltype from the field being assigned keeps the type identical, is immune to the check, and matches the max_retries cast two lines above that already uses this form. Co-Authored-By: Claude Opus 5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units71 translation units recompiled, 747 s compile time in total, 71 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.18 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
The first version of this change also lowered the credential connect timeout to DEFAULT_CONNECT_TIMEOUT_MS. That was unrequested scope and it narrowed a supported contract. `metadata_service` is a user-configurable host (S3AuthSettings.cpp:43), so the connect budget for reaching it belongs to the deployment that configured it, and the metadata branch of requestBearerToken has no retry loop, which makes a single premature connect failure terminal there. The STS clamp is not a precedent for it either: every production caller passes an empty sts_endpoint_override, so that path only ever dials AWS's own regional endpoint, and it pairs its 1 s connect cap with a bounded retry strategy. Connect was never the unbounded phase. BackupIO_S3 already bounds it at 10 s, and the reported 695 s stall was entirely in the response wait, which Poco leaves at max(receive, send) through SecureSocketImpl::getMaxTimeoutOrLimit. Capping the response wait alone fixes the hang. The connect_cases arm of the gtest now pins the pass-through instead of the cap; reintroducing the clamp locally fails it, along with the data-plane arm.
CI finish ledger - 3afa3efEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
CI finished clean on this head, so no row needs an owner: 147 checks succeeded, 24 were Session id: cron:our-pr-ci-monitor:20260820-113000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a hang of up to one hour in
BACKUP/RESTORE ... TO S3, GCS disks and thes3table function when the named collection setshttp_client = 'gcp_oauth'and the Google OAuth2 token endpoint accepts the connection but never answers. The bearer token request no longer inherits the caller's data transfer request timeout; its response wait is bounded at 10 seconds, matching the STSAssumeRolerequest cap.Description
Found in CI:
BACKUP TABLE ... TO S3(<collection with http_client = 'gcp_oauth'>)sat for 695 s withread_rows: 0until the test budget expired and the job reportedSome queries hung. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107108&sha=7b0f0efd7803a3f3a603fe10adf92811bf16f468&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20old%20analyzer%2C%20s3%20storage%2C%20DBReplicated%2C%20WasmEdge%2C%20parallel%2C%203%2F3%29BackupIO_S3.cppsetsrequestTimeoutMs = 60 * 60 * 1000because backup data transfers can legitimately take that long. That single value becomes both the send and the receive socket timeout, andPocoHTTPClientGCPOAuthreuses the sametimeoutsmember for its bearer token round trip, so a credential request that should take milliseconds parked in the TLS header read for an hour (SecureSocketImpl::mustRetryunderHTTPHeaderStreamBuf::readFromDevice). The S3 endpoint in the failing case is plain HTTP on localhost, so the TLS peer can only be the hardcoded Google token URL.This bounds the response wait of that round trip at 10 seconds, independently of the data transfer timeouts, at both mint sites (explicit ADC triple, and the metadata service branch). The connect timeout is left as the caller set it:
metadata_serviceis a user-configurable host, so its connect budget belongs to the deployment that configured it, and connect was never the unbounded phase (BackupIO_S3already bounds it at 10 s). Data plane requests keep the full hour, and an already tighter timeout is kept. The 10 s matches the STSAssumeRolerequest cap, so it is named once inS3Defines.h.Validated against a mock that accepts and never answers: the value passed before was still blocked after 40 s, the value passed now fails in 10.0 s. Exactly one request arrived in each arm, so
backup_restore_s3_retry_attempts(default 1000) does not multiply the mint.Not bounded here: session creation is retried up to 5 times, each attempt carrying the caller's connect budget, and the mint is not cancellation aware within the 10 s.
Workflow [PR]
Sync PR [sync-upstream/pr/115531]
Version info
26.8.1.1803(included in26.8and later)