Skip to content

Commit a900d9e

Browse files
committed
Handle status code 200 for s3 CMU response (elastic#122815)
When a CopmleteMultipartUpload request fails after the initial 200 response, the status code of the failure response use to be not set and hence got translated to status code 0. With elastic#116212, we handle this case accordingly. Since AWS SDK 1.12.691, the status code is now set to 200 instead of 0. This PR changes our error handling code accordingly. Relates: elastic#122431 Relates: elastic#116212 Resolves: elastic#122799 Relevant AWS SDK change https://github.com/aws/aws-sdk-java/blame/430899c217f34fae63b35c77f4d9bfd361c9de77/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L3696-L3709 (cherry picked from commit 850249b) # Conflicts: # muted-tests.yml
1 parent 7637b6b commit a900d9e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobContainer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,10 @@ public void compareAndExchangeRegister(
884884
logger.trace(() -> Strings.format("[%s]: compareAndExchangeRegister failed", key), e);
885885
if (e instanceof AmazonS3Exception amazonS3Exception
886886
&& (amazonS3Exception.getStatusCode() == 404
887-
|| amazonS3Exception.getStatusCode() == 0 && "NoSuchUpload".equals(amazonS3Exception.getErrorCode()))) {
887+
|| amazonS3Exception.getStatusCode() == 200 && "NoSuchUpload".equals(amazonS3Exception.getErrorCode()))) {
888888
// An uncaught 404 means that our multipart upload was aborted by a concurrent operation before we could complete it.
889889
// Also (rarely) S3 can start processing the request during a concurrent abort and this can result in a 200 OK with an
890-
// <Error><Code>NoSuchUpload</Code>... in the response, which the SDK translates to status code 0. Either way, this means
891-
// that our write encountered contention:
890+
// <Error><Code>NoSuchUpload</Code>... in the response. Either way, this means that our write encountered contention:
892891
delegate.onResponse(OptionalBytesReference.MISSING);
893892
} else {
894893
delegate.onFailure(e);

0 commit comments

Comments
 (0)