Repository navigation
feat(rest): align HTTP retries and timeouts with Java #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zhjwpku
wants to merge
5
commits into
apache:main
Choose a base branch
from
zhjwpku:rest-http-client-transport
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,781
−121
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2e15601
feat(rest): align HTTP retries and timeouts with Java
zhjwpku 46e20f9
refactor(rest): improve transport testability and coverage
zhjwpku 7eb8420
fix(rest): resolve Windows macro conflicts and CI lint errors
zhjwpku 4c67304
refactor(rest): separate OAuth response redaction from transport
zhjwpku cfabc7d
fix(util): guard string comparison against Windows min macro
zhjwpku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ with the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
|
|
||
| # REST catalog transport | ||
|
|
||
| The transport and retry properties follow the Java `HTTPClient` and | ||
| `ExponentialHttpRequestRetryStrategy`. They apply to configuration discovery, | ||
| OAuth token requests, catalog operations, and storage credential refresh requests. | ||
| Initial requests use client properties; subsequent requests use merged catalog | ||
| properties. | ||
|
|
||
| | Property | Default | Notes | | ||
| | --- | --- | --- | | ||
| | `rest.client.connection-timeout-ms` | 180000 | Non-negative integer; zero disables the configured deadline | | ||
| | `rest.client.socket-timeout-ms` | Unbounded | Non-negative integer; zero disables the response inactivity timeout | | ||
| | `rest.client.max-retries` | 5 | Positive integer; excludes the first attempt; does not bound total wait time | | ||
| | `rest.client.user-agent` | `iceberg-cpp/<version>` | Used when the request has no explicit `User-Agent` header | | ||
| | `rest.client.idempotency-key-lifetime` | Unbounded | ISO-8601 duration, for example `PT30M`; zero or negative durations disable keyed retries; malformed or out-of-range values are ignored | | ||
|
|
||
| The socket timeout measures response inactivity rather than average transfer | ||
| speed or total request duration. It does not bound request-body uploads. The | ||
| legacy `HttpClient` constructor's third argument remains a total timeout per | ||
| attempt. Transfers run synchronously in the calling thread; no executor is | ||
| required for HTTP retries. | ||
|
|
||
| HTTP response retries are decided after receiving the headers, before reading | ||
| the response body: | ||
|
|
||
| - HTTP 429, and HTTP 503 carrying `Retry-After`, permit retries for any method. | ||
| - GET, HEAD and DELETE, and requests carrying an `Idempotency-Key` header, also | ||
| permit retries on HTTP 408, 500, 502, 503 and 504. | ||
| - Positive numeric and HTTP-date `Retry-After` values are honored. Otherwise the | ||
| wait doubles from 1 second up to 64 seconds, with up to 10% jitter. Invalid or | ||
| non-positive values use this backoff; numeric durations beyond the millisecond | ||
| range saturate at the maximum representable duration. | ||
|
|
||
| Recoverable I/O failures before response headers are received permit retries | ||
| for idempotent methods or requests carrying `Idempotency-Key`. As in Java's | ||
| I/O-exception retry path, these retries have no delay. Name resolution, | ||
| connection, TLS, timeout, cancellation and premature-response-closure failures | ||
| are not retried. Failures while reading a final response body are propagated, | ||
| including when its HTTP status was successful. | ||
|
|
||
| For keyed requests, the lifetime starts at the first send. A retry is abandoned | ||
| when elapsed time plus the maximum next retry interval reaches the configured | ||
| lifetime. The bound includes `Retry-After` or the largest possible HTTP backoff | ||
| jitter. As in Java, the I/O-error lifetime check uses the exponential interval | ||
| even though the exception retry itself has no delay. Unkeyed requests are not | ||
| constrained by this property. | ||
|
|
||
| Authentication runs once before the first send. Retries replay the same | ||
| headers, body and idempotency key. A subsequent logical request authenticates | ||
| again and can use an updated token. | ||
|
|
||
| The client does not generate idempotency keys. Supply a distinct key for each | ||
| logical mutation through per-request headers or an `AuthSession`. A static | ||
| `header.Idempotency-Key` is unsuitable for unrelated mutations. | ||
|
|
||
| Errors are classified from the `code` reported in the error body, falling back | ||
| to the HTTP status when the body cannot be parsed. Service diagnostics remain | ||
| available. | ||
|
|
||
| Other Java transport options, including `rest.client.max-connections`, | ||
| `rest.client.connections-per-route`, `rest.client.proxy.*` and | ||
| `rest.client.tls.configurer-impl`, are not yet supported by this transport. | ||
|
|
||
| For temporary storage credentials and their lifetime, see [FileIO](file-io.md#refreshing-temporary-s3-credentials). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This anchor does not exist in file-io.md. Please link to #storage-credentials or add the referenced section.