Skip to content
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

S3: ReadTimeoutException #954

Closed
ben-manes opened this issue Dec 14, 2018 · 8 comments
Closed

S3: ReadTimeoutException #954

ben-manes opened this issue Dec 14, 2018 · 8 comments
Labels
bug This issue is a bug. pending-release This issue will be fixed by an approved PR that hasn't been released yet.

Comments

@ben-manes
Copy link

ben-manes commented Dec 14, 2018

When uploading large PDFs from S3 (hundreds of megabytes), I am seeing a timeout failure. It could be due to having configured some sanity timeouts, since I saw the client hang forever. I configured the client as below. I would expect the timeout of 15 minutes to be enough for file of this size.

@Provides @Singleton
S3AsyncClient providesS3AsyncClient(AwsCredentialsProvider credentials) {
  return S3AsyncClient.builder()
      .region(Region.of(config.getString("region")))
      .credentialsProvider(credentials)
      .overrideConfiguration(builder -> builder
        .apiCallTimeout(/* 45 min */)
        .apiCallAttemptTimeout(/* 15 min */)
      ).build();
}
io.netty.handler.timeout.ReadTimeoutException: null
Wrapped by: java.io.IOException: Read timed out
	at software.amazon.awssdk.http.nio.netty.internal.ResponseHandler.wrapException(ResponseHandler.java:363)
	at software.amazon.awssdk.http.nio.netty.internal.ResponseHandler.exceptionCaught(ResponseHandler.java:121)
	... 42 common frames omitted
Wrapped by: software.amazon.awssdk.core.exception.SdkClientException: null
	at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:97)
	at software.amazon.awssdk.core.internal.util.ThrowableUtils.asSdkException(ThrowableUtils.java:98)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryExecutor.retryIfNeeded(AsyncRetryableStage.java:117)
	... 49 common frames omitted
Wrapped by: java.util.concurrent.CompletionException: software.amazon.awssdk.core.exception.SdkClientException
	at software.amazon.awssdk.utils.CompletableFutureUtils.errorAsCompletionException(CompletableFutureUtils.java:61)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncExecutionFailureExceptionReportingStage.lambda$execute$0(AsyncExecutionFailureExceptionReportingStage.java:50)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:930)
	at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:907)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryExecutor.retryErrorIfNeeded(AsyncRetryableStage.java:166)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryExecutor.retryIfNeeded(AsyncRetryableStage.java:118)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryExecutor.lambda$execute$0(AsyncRetryableStage.java:103)
	at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
	at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage$ResponseHandler.onError(MakeAsyncHttpRequestStage.java:236)
	at software.amazon.awssdk.http.nio.netty.internal.ResponseHandler.exceptionCaught(ResponseHandler.java:122)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at com.typesafe.netty.HandlerSubscriber.exceptionCaught(HandlerSubscriber.java:157)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at software.amazon.awssdk.http.nio.netty.internal.FutureCancelHandler.exceptionCaught(FutureCancelHandler.java:47)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireExceptionCaught(CombinedChannelDuplexHandler.java:426)
	at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:87)
	at io.netty.channel.CombinedChannelDuplexHandler$1.fireExceptionCaught(CombinedChannelDuplexHandler.java:147)
	at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
	at io.netty.channel.CombinedChannelDuplexHandler.exceptionCaught(CombinedChannelDuplexHandler.java:233)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at io.netty.handler.ssl.SslHandler.exceptionCaught(SslHandler.java:1074)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:87)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
	at io.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:98)
	at io.netty.handler.timeout.ReadTimeoutHandler.channelIdle(ReadTimeoutHandler.java:90)
	at io.netty.handler.timeout.IdleStateHandler$ReaderIdleTimeoutTask.run(IdleStateHandler.java:494)
	at io.netty.handler.timeout.IdleStateHandler$AbstractIdleTask.run(IdleStateHandler.java:466)
	at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
	at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:127)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
	at java.base/java.lang.Thread.run(Thread.java:844)
@ben-manes
Copy link
Author

Still see this after upgrading to 2.2.0.

@zoewangg zoewangg added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Dec 20, 2018
@oakad
Copy link

oakad commented Dec 24, 2018

Yep, getting this as well. Had to ramp up my read timeout setting to some outrageous value, like 60 minutes.

Also, there's another issue with netty, when multiple async requests are in progress: "server returned incomplete data". Kind of difficult to trigger, but it is there all right.

@zoewangg zoewangg added the bug This issue is a bug. label Jan 9, 2019
@zoewangg
Copy link
Contributor

Apologies for the delay. I was able to reproduce the error by uploading 400MB object with default configuration. All retry attempts failed. Investigating.

@zoewangg
Copy link
Contributor

I increased the Netty clientreadTimeout to 50 seconds (the default socketReadTimeout is 30 seconds) and the request succeeded in the first attempt.

        s3Async = s3AsyncClientBuilder()
        .httpClient(NettyNioAsyncHttpClient.builder().readTimeout(Duration.ofSeconds(50)).build())
        .build();

We will discuss and revisit the default configuration. Same request using ApacheHttpClient with the same default 30s socketReadTimeout always succeeds though.

@zoewangg zoewangg removed the bug This issue is a bug. label Jan 10, 2019
@zoewangg
Copy link
Contributor

@oakad Could you create another issue regarding the "server returned incomplete data" since it's a different issue?

@ben-manes
Copy link
Author

I had to switch back to v1 which has been very stable. You might want to review their timeout, etc setting for good defaults.

@oakad
Copy link

oakad commented Jan 10, 2019

@zoewangg I'm working on something else atm, but if and when I can trigger that error with a decent stack trace I will open the issue.

As to the present issue, it is much easier to trigger it on a slow connection. I'd even say that it feels like read timeout is being measured from the start of upload (which would be incorrect). Rather, it will make more sense to monitor the connection for the upload progress being made and only engage the read timeout when waiting for server response.

@zoewangg zoewangg added the bug This issue is a bug. label Jan 14, 2019
@zoewangg zoewangg mentioned this issue Jan 15, 2019
13 tasks
@zoewangg zoewangg added awaiting-review and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. awaiting-review labels Jan 21, 2019
@zoewangg
Copy link
Contributor

After investigating, this one was an issue of SDK use of netty ReadTimeoutHandler for the PutObjectRequest. Fixed via #1015 and was released in the latest version.

Closing the issue, feel free to reopen if you have further questions.

@justnance justnance added pending-release This issue will be fixed by an approved PR that hasn't been released yet. and removed awaiting-release labels Apr 19, 2019
aws-sdk-java-automation added a commit that referenced this issue Sep 14, 2020
…60c6179c

Pull request: release <- staging/c38a7134-93cb-4c57-a609-b36b60c6179c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. pending-release This issue will be fixed by an approved PR that hasn't been released yet.
Projects
None yet
Development

No branches or pull requests

4 participants