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

Stack trace / exceptions when uploading with aws-chunked are not helpful #791

Open
lauzadis opened this issue Feb 2, 2023 · 0 comments
Open
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@lauzadis
Copy link
Contributor

lauzadis commented Feb 2, 2023

Describe the bug

When making a request using aws-chunked Content-Encoding that leads to a service-level exception, the stack trace is not helpful for revealing the root cause of the exception.

Expected Behavior

When uploading a small file (not using aws-chunked) the service error is readable:

Exception in thread "main" aws.sdk.kotlin.services.s3.model.S3Exception: The provided token is malformed or otherwise invalid.
	at aws.sdk.kotlin.services.s3.transform.PutObjectOperationDeserializerKt.throwPutObjectError(PutObjectOperationDeserializer.kt:66)
	at aws.sdk.kotlin.services.s3.transform.PutObjectOperationDeserializerKt.access$throwPutObjectError(PutObjectOperationDeserializer.kt:1)
	at aws.sdk.kotlin.services.s3.transform.PutObjectOperationDeserializerKt$throwPutObjectError$1.invokeSuspend(PutObjectOperationDeserializer.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at DeleteObjectsChecksumRequiredKt.main(DeleteObjectsChecksumRequired.kt:14)
	at DeleteObjectsChecksumRequiredKt.main(DeleteObjectsChecksumRequired.kt)

Current Behavior

Exception in thread "main" kotlinx.coroutines.JobCancellationException: Parent job is Cancelling; job=JobImpl{Cancelled}@ec2cc4
Caused by: java.net.SocketException: Connection reset by peer (Write failed)
	at java.base/java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:110)
	at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:150)
	at java.base/sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:345)
	at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1304)
	at okio.OutputStreamSink.write(JvmOkio.kt:57)
	at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:102)
	at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:255)
	at okio.RealBufferedSink.write(RealBufferedSink.kt:146)
	at okhttp3.internal.http1.Http1ExchangeCodec$ChunkedSink.write(Http1ExchangeCodec.kt:310)
	at okio.ForwardingSink.write(ForwardingSink.kt:29)
	at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:223)
	at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:255)
	at okio.RealBufferedSink.write(RealBufferedSink.kt:146)
	at okio.RealBufferedSink.emit(RealBufferedSink.kt:261)
	at aws.smithy.kotlin.runtime.io.AbstractBufferedSinkAdapter.emit(BufferedSinkAdapter.kt:73)
	at aws.smithy.kotlin.runtime.io.SdkByteReadChannelKt$readAll$2.invokeSuspend(SdkByteReadChannel.kt:114)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
	Suppressed: java.net.SocketException: Socket closed
		at java.base/java.net.SocketInputStream.socketRead0(Native Method)
		at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
		at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
		at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
		at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
		at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
		at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
		at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1454)
		at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:1065)
		at okio.InputStreamSource.read(JvmOkio.kt:94)
		at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:128)
		at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:427)
		at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:320)
		at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
		at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:179)
		at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:111)
		at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:95)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:65)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205)
		at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:537)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
		at java.base/java.lang.Thread.run(Thread.java:829)

Steps to Reproduce

  1. Make an S3 client with invalid / missing credentials
  2. Upload a 1kb file
  3. Observe the service error in the stack trace
  4. Upload a 10mb file
  5. Observe an unreadable / unhelpful stack trace

Possible Solution

The problem is likely caused by the way the SDK handles coroutine teardown when a request fails.

Context

Your Environment

  • Smithy Kotlin version used: 0.15.2-SNAPSHOT
  • Platform (JVM/JS/Native): JVM
  • Operating System and version: MacOS Monterey 12.6.3
@lauzadis lauzadis added the bug This issue is a bug. label Feb 2, 2023
@ianbotsf ianbotsf added the p2 This is a standard priority issue label Apr 4, 2024
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. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants