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

SegmentNotFoundException when using S3 TransferManager to multiPart upload files, tracing by AWS XRay #3217

Closed
Zhenye-Na opened this issue May 27, 2022 · 4 comments
Labels
bug This issue is a bug.

Comments

@Zhenye-Na
Copy link

Describe the bug

Existing rasied issues:

Basically the problem is that transferManager manages its own thread pool and XRay is not able to gather context for the threads that transferManager created. In this case, SegmentNotFoundException has been raised

Expected Behavior

TransferManager should be compatible with XRay for request tracing

Current Behavior

SegmentNotFoundException is raised

Reproduction Steps

S3 Multipart Upload High Level API - https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpu-upload-object.html

import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
import com.amazonaws.services.s3.transfer.Upload;

import java.io.File;

public class HighLevelMultipartUpload {

    public static void main(String[] args) throws Exception {
        Regions clientRegion = Regions.DEFAULT_REGION;
        String bucketName = "*** Bucket name ***";
        String keyName = "*** Object key ***";
        String filePath = "*** Path for file to upload ***";

        try {
            AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                    .withRegion(clientRegion)
                    .withCredentials(new ProfileCredentialsProvider())
                    .build();
            TransferManager tm = TransferManagerBuilder.standard()
                    .withS3Client(s3Client)
                    .build();

            // TransferManager processes all transfers asynchronously,
            // so this call returns immediately.
            Upload upload = tm.upload(bucketName, keyName, new File(filePath));
            System.out.println("Object upload started");

            // Optionally, wait for the upload to finish before continuing.
            upload.waitForCompletion();
            System.out.println("Object upload complete");
        } catch (AmazonServiceException e) {
            // The call was transmitted successfully, but Amazon S3 couldn't process 
            // it, so it returned an error response.
            e.printStackTrace();
        } catch (SdkClientException e) {
            // Amazon S3 couldn't be contacted for a response, or the client
            // couldn't parse the response from Amazon S3.
            e.printStackTrace();
        }
    }
}

and on top of this, using XRay to trace the request

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

AWSS3JavaClient = 1.12.x

JDK version used

JDK 8

Operating System and version

Amazon Linux 2

@debora-ito
Copy link
Member

Hi @Zhenye-Na thank you for reaching out.

We got the same issue reported but for X-Ray and the SDK client-side metrics here: #2919. As it's mentioned in the comments, it's not something we can fix on the SDK side without X-Ray support.

We've opened an issue in the X-Ray SDK repo and we're tracking progress over there: aws/aws-xray-sdk-java#330.

Let us know if this helps.

@debora-ito debora-ito added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 8, 2022
@Zhenye-Na
Copy link
Author

Thanks, I subscribed the issue you created. Let's see what X-Ray team replies and how to sort this out.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Jun 9, 2022
@debora-ito
Copy link
Member

Hi @Zhenye-Na, I'll go ahead and close this issue since we cannot move forward in the SDK without the support from the X-Ray team.
Please use aws/aws-xray-sdk-java#330 for tracking.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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.
Projects
None yet
Development

No branches or pull requests

2 participants