GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(gax): add chunk upload recovery loop for resumable uploads by whowes · Pull Request #14424 · googleapis/google-cloud-java Conversation
|
|
/gemini review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces a recovery mechanism for resumable uploads by integrating query status calls when chunk uploads encounter recoverable errors or return unknown statuses. The ResumableUploadChunkCoordinator now queries the server for the committed offset, realigns the buffer, and resumes transmission. Feedback on these changes highlights a missing import for the @nullable annotation in ResumableUploadChunkCoordinator that will cause a compilation failure, as well as a recommendation to limit consecutive recovery attempts to prevent potential infinite loops.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| import com.google.api.gax.resumable.QueryStatusRequest; | ||
| import com.google.api.gax.resumable.QueryStatusResponse; | ||
| import com.google.api.gax.resumable.ResumableUploadStatus; | ||
| import com.google.api.gax.rpc.ResumableUploadErrorClassifier.Category; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The @Nullable annotation is used in this file (on line 269) but org.jspecify.annotations.Nullable is not imported. This will cause a compilation error. Please add the import.
| import com.google.api.gax.rpc.ResumableUploadErrorClassifier.Category; | |
| import com.google.api.gax.rpc.ResumableUploadErrorClassifier.Category; | |
| import org.jspecify.annotations.Nullable; |
@Nullable annotations to document nullability, even if doing so temporarily triggers static analysis warnings.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
False positive; this import is present in the file as the final import.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| } | ||
|
|
||
| private void recover() { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
To prevent infinite loops of recovery attempts (for example, if a 400 Bad Request is caused by a persistent non-alignment issue, the query status will repeatedly return the same committed offset, leading to an endless cycle of upload -> fail -> query -> realign -> upload), we should limit the number of consecutive recovery attempts.
Consider adding an instance variable to track consecutive recovery attempts:
private int consecutiveRecoveryAttempts = 0; private static final int MAX_CONSECUTIVE_RECOVERY_ATTEMPTS = 3;
Reset this counter to 0 in onChunkUploaded when a chunk is successfully acknowledged, and increment/check it in recover().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Our requirements dictate a global timeout for the upload to prevent such situations; enforcement of this will be present in the next PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1e2a630 to
ca7da1b
Compare
ca7da1b to
4621a6f
Compare
4621a6f to
2bf5fb5
Compare
| "Upload stream ended and final chunk was transmitted, but server returned" | ||
| + " incomplete status")); | ||
| if (response.getUploadStatus() == ResumableUploadStatus.UNKNOWN) { | ||
| recover(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add some backoff time before recovering? I'm worries that there might be cases causing constant recovering and there could be thousands of requests fired in a short amount of time.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I added exponential backoff here using the same retry settings as for transient retries (including enforcing the max attempts when no progress is made on a round of recoveries).
I think this addition comes close to justifying taking the refactor another step to something similar to ServerStreamingAttemptCallable but given our timeline I'm inclined to stop here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "Query status response missing X-Goog-Upload-Status header for upload URL: " + uploadUrl); | ||
| } | ||
| if (queryResponse.getUploadStatus() == ResumableUploadStatus.FINAL) { | ||
| onChunkUploaded( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
onChunkUploaded does another status check and sets the response. Can we set the result directly here?
In general, I feel there might be too many abstraction layers now such as handleQueryResponse, onChunkUploaded, transmitChunk and dispatchCurrentChunk. They all seem similar and it's hard to follow the actual upload flow.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
FINAL query responses now set the result directly.
I merged/reworked the layers some (dispatchCurrentChunk is folded into transmitChunk, and onChunkUploaded is now handleChunkResponse).
The flow is now transmitChunk → handleChunkResponse for the error-free upload path, and queryStatus → handleQueryResponse → transmitChunk when there's a recoverable error. recover is the transition between them and applies backoff. On paper this doesn't seem like much of a simplification, but with backoff we now need a non-trivial transition step.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| createRetryingCallable( | ||
| client.queryStatusCallable(), ResumableUploadCommand.QUERY, clientContext); | ||
| this.recoveryAlgorithm = | ||
| new ExponentialRetryAlgorithm(RETRY_SETTINGS, clientContext.getClock()); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This should be fine for now. But we may want to give the default values more thought later, because retry and recovery may have different use cases that require different defaults.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Introduces a query-and-realign loop when encountering recoverable protocol errors during chunk uploads. Queries the server for the committed offset and adjusts the buffer window before resuming chunk transmission.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.