-
When uploading an object with multipart upload. I occassionally get I also noticed that this error would only happen when the data passed into fn get_upload_body(data: Vec<Bytes>) -> aws_sdk_s3::types::ByteStream {
Body::wrap_stream(stream::iter(data.into_iter().map(ObjectResult::Ok))).into()
}
client_cloned
.upload_part()
.bucket(bucket)
.key(key)
.upload_id(upload_id)
.part_number(part_id)
.body(get_upload_body(data))
.content_length(len as i64)
.send()
.await
.map_err(ObjectError::s3); will occasionally return with an error, while concatenating the fn get_upload_body(data: Bytes) -> aws_sdk_s3::types::ByteStream {
aws_sdk_s3::types::ByteStream::from(data)
} will never return an error. I have searched it online a bit already, and according to this issue, it seems to be related to a race condition in hyper. However, no matter how short I set the client-side keep-alive timeout (by passing in a custom hyper client), the error persists. With all that said, my questions are:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think that by converting use aws_smithy_http::body::SdkBody;
use std::convert::Infallible;
use tokio_stream as stream;
fn get_upload_body(data: Vec<bytes::Bytes>) -> aws_sdk_s3::types::ByteStream {
SdkBody::retryable(move || {
SdkBody::from(hyper::Body::wrap_stream(stream::iter(
data.clone().into_iter().map(Result::<_, Infallible>::Ok),
)))
})
.into()
} Also, if you're using Tokio's single-threaded runtime, there is a bug that makes |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
I think that by converting
hyper::Body
into aByteStream
, you're inadvertently disabling retry for the operation since the SDK has no way to restart the stream in the event of failure. If you're streaming from a file, then you can useByteStream::from_path
to get streaming retry. Otherwise, you should useSdkBody::retryable
to create anSdkBody
, and then convert thatSdkBody
into aByteStream
. For example: