Skip to content

fix(storage): preserve HTTP status for XML multipart upload errors so retries work - #14804

Merged
Dhriti07 merged 4 commits into
googleapis:mainfrom
Dhriti07:fix/mpu-xml-retry
Oct 29, 2026
Merged

Dhriti07 merged 4 commits into
googleapis:mainfrom
Dhriti07:fix/mpu-xml-retry

Conversation

@Dhriti07

@Dhriti07 Dhriti07 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MultipartUploadClient (XML multipart upload API) never retried retryable HTTP responses such as 503 Service Unavailable, even for idempotent operations like uploadPart, despite default RetrySettings (maxAttempts: 6).

Root cause

MultipartUploadHttpRequestManager executes raw HttpRequests with setThrowExceptionOnExecuteError(true), so an error response surfaces as a plain HttpResponseException. Unlike HttpStorageRpc, MultipartUploadClientImpl did not translate that IOException, so it reached the catch-all in Retrying.DefaultRetrier, which calls StorageException.coalesce(e). coalesce is a generic fallback and (as documented) creates a StorageException with UNKNOWN_CODE (0). With code 0, DefaultStorageRetryStrategy cannot classify the error and returns NO_RETRY.

Fix

Wrap each MultipartUploadClientImpl operation so any IOException is converted via StorageException.translate(...) before reaching the retrier.

… retries work

MultipartUploadClientImpl sends raw XML API requests that throw a plain HttpResponseException on error. These were not translated, so the retrier's catch-all coalesced them into a StorageException with code 0, and the retry strategy could not classify them. As a result, retryable responses (408, 429, 5xx) were never retried, even for idempotent operations such as uploadPart, and callers saw getCode() == 0.

Translate IOExceptions via StorageException.translate inside each MultipartUploadClient operation, matching HttpStorageRpc, so the HTTP status code is preserved and retries follow the standard rules. createMultipartUpload remains non-idempotent and is not retried.
@Dhriti07
Dhriti07 requested review from a team as code owners October 28, 2026 08:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates MultipartUploadClientImpl to translate IOExceptions into StorageExceptions before they reach the retrier, ensuring that HTTP status codes are preserved and transient errors can be properly classified and retried. It also introduces a comprehensive integration test suite in ITMultipartUploadClientRetryTest.java to verify this retry behavior. Feedback on the tests suggests optimizing uploadPart_retriesAllRetryableStatusCodes by instantiating the FakeHttpServer once outside the loop to avoid the overhead of repeatedly starting and stopping the server.

@Dhriti07
Dhriti07 requested a review from ShreyasSinha October 28, 2026 09:16
@Dhriti07
Dhriti07 merged commit 3c03034 into googleapis:main Oct 29, 2026
203 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants