-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(gax): retry chunk upload on transient errors #14422
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ | |
| import java.io.InputStream; | ||
| import java.util.Arrays; | ||
| import java.util.concurrent.CancellationException; | ||
| import java.util.concurrent.Executor; | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
|
|
@@ -59,6 +60,10 @@ final class ResumableUploadChunkCoordinator<ResponseT> { | |
|
|
||
| private static final byte[] EMPTY_PAYLOAD = new byte[0]; | ||
|
|
||
| // Serializes buffer mutations across multiple threads (i.e. from retry/recovery) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a case for "serializing buffer mutations across multiple threads"? retry/recovery is always sequential. |
||
| private final Executor chunkExecutor = | ||
| MoreExecutors.newSequentialExecutor(MoreExecutors.directExecutor()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this to prevent stackoverflow of the sequential transmitChunk call? If it is, I don't think it would happen because each call will be run in a separate IOExecutor thread. |
||
|
|
||
| private final UnaryCallable<ChunkUploadRequest, ChunkUploadResponse<ResponseT>> | ||
| uploadChunkCallable; | ||
| private final String uploadUrl; | ||
|
|
@@ -93,7 +98,7 @@ ApiFuture<ResponseT> start() { | |
| } | ||
| }, | ||
| MoreExecutors.directExecutor()); | ||
| transmitChunk(0L); | ||
| chunkExecutor.execute(() -> transmitChunk(0L)); | ||
| return result; | ||
| } | ||
|
|
||
|
|
@@ -157,9 +162,10 @@ public void onSuccess(ChunkUploadResponse<ResponseT> response) { | |
| result.setException( | ||
| new IllegalStateException( | ||
| "Upload stream ended and final chunk was transmitted, but server returned" | ||
| + " incomplete status")); | ||
| + " incomplete status for upload URL: " | ||
| + uploadUrl)); | ||
|
Comment on lines
162
to
+166
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Including the full result.setException(
new IllegalStateException(
"Upload stream ended and final chunk was transmitted, but server returned"
+ " incomplete status"));
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving the URL in - it's a requirement that the URL is included in failure messages when possible. (I actually have a subsequent PR which expands that behavior). |
||
| } else { | ||
| transmitChunk(nextOffset); | ||
| chunkExecutor.execute(() -> transmitChunk(nextOffset)); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should at least set
initialRpcTimeoutDurationandtotalTimeoutDuration. Otherwise the call could hang indefinitely (before global timeout kicks in). These are the default generated retrySetting values.Separately, check if there is a cross-language sensible default.