gtrettenero opened a new pull request, #19326:
URL: https://github.com/apache/iceberg/pull/19326
## Problem
`S3FileIO` builds its S3 client without an API call attempt timeout. The
HTTP client's socket timeout only bounds reads. If an attempt's connection
silently stops accepting request body bytes, the calling thread blocks in a
socket write, and nothing in the client can stop it.
Example: an `UploadPart` whose TCP peer stops acknowledging data. The write
is only abandoned when the kernel gives up retransmitting. With default Linux
settings (`net.ipv4.tcp_retries2 = 15`) that takes about 15 minutes. Only then
does the SDK retry, and the retry usually succeeds immediately.
We see this in production with streaming writers: a single part upload
stalls for 625–955 s while sibling uploads on the same host complete normally.
That blocks the file close and everything waiting on it, for example a Flink
checkpoint.
The stalled thread looks like this:
```
"iceberg-s3fileio-upload-10" RUNNABLE
at sun.nio.ch.Net.poll(Native Method)
at sun.nio.ch.NioSocketImpl.park(NioSocketImpl.java:191)
at sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:412)
at java.net.Socket$SocketOutputStream.write(Socket.java:1195)
at
sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:345)
...
at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(...)
...
at
software.amazon.awssdk.services.s3.DefaultS3Client.uploadPart(DefaultS3Client.java:...)
at
org.apache.iceberg.aws.s3.S3OutputStream.lambda$uploadParts$2(S3OutputStream.java:327)
```
Its CPU time is unchanged across dumps taken 10 minutes apart.
## Change
- Adds an optional `s3.api-call-attempt-timeout-ms` property to
`S3FileIOProperties`. When set, `applyRetryConfigurations` sets
`ClientOverrideConfiguration#apiCallAttemptTimeout`.
- On timeout the SDK aborts the in-flight request, which closes the
connection and unblocks the write. It then retries on a new connection under
the existing `s3.retry.*` policy.
- The property is not set by default, so behavior is unchanged unless
configured. Zero or negative values are rejected.
- Documents the property in `aws.md`.
The property name mirrors the existing `s3.retry.*` settings. I'm open to a
client-wide `client.*` property in `AwsClientProperties` instead, if reviewers
prefer one that also covers Glue, DynamoDB and other clients.
## Testing
- **Unit tests in `TestS3FileIOProperties`:**
- not set by default;
- applied alongside the retry policy;
- preserves an existing override configuration;
- rejects non-positive values.
- **`TestS3ApiCallAttemptTimeout`:**
- **Setup:** a local server accepts connections, answers `Expect:
100-continue`, and then never reads the body. A 64 MiB `PutObject` through
`DefaultS3FileIOAwsClientFactory` blocks in `NioSocketImpl.implWrite`.
- **With the property set to 2 s and one retry:** the call fails with
`ApiCallAttemptTimeoutException` after about 4 s, and the server sees two
connections, which shows the retry used a fresh connection.
- **Manual control, without the property:** the same upload was still
blocked in the socket write after 45 s, past the default 30 s socket timeout.
It only failed when the test closed the server socket.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]