GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@whowes

@whowes whowes commented Sep 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Introduces a query/realign loop for error recovery during chunk uploads. Queries the server for the committed offset and adjusts the buffer window before resuming chunk transmission. Transient errors on query are retried via a typical decorated Callable. Recoveries are spaced with exponential backoff and bounded by a max attempt count that resets on progress.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from f7dacda to ea2e309 Compare September 17, 2026 22:08
gemini-code-assist[bot]

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@whowes
whowes added this pull request to stack #14429 September 17, 2026 22:16
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from ea2e309 to e197ee8 Compare September 17, 2026 22:22
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from e197ee8 to 12cd1cb Compare September 18, 2026 02:23
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 12cd1cb to dd1aaac Compare September 18, 2026 03:01
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from dd1aaac to 7fb2335 Compare September 18, 2026 03:21
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 7fb2335 to 4795631 Compare September 18, 2026 15:05
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 4795631 to 1fe75dc Compare September 19, 2026 01:36
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 1fe75dc to 8456db3 Compare September 19, 2026 21:12
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 8456db3 to 04da457 Compare September 19, 2026 22:57
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 04da457 to f60b76a Compare September 19, 2026 23:17
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from f60b76a to d5c48d6 Compare September 20, 2026 00:19
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from d5c48d6 to 599ab38 Compare September 20, 2026 05:24
@whowes whowes mentioned this pull request Sep 20, 2026
feat(gax): add RewindableStreamBuffer in prep for chunk upload recovery #14423
Merged
@whowes
whowes removed this pull request from stack #14429 September 20, 2026 07:20
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 599ab38 to 292921f Compare September 20, 2026 07:45
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 56bfa8e to 566ca01 Compare September 22, 2026 08:52
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 566ca01 to f9ca3dc Compare September 22, 2026 15:49
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch 2 times, most recently from 866799e to 387f05d Compare September 22, 2026 16:31
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 387f05d to caa3938 Compare September 22, 2026 16:45
@whowes
whowes added this pull request to stack #14476 September 22, 2026 18:08
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch 2 times, most recently from 37d9c76 to ebdf2fb Compare September 22, 2026 19:37
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch 2 times, most recently from 4b1c1b0 to 1e2a630 Compare September 22, 2026 20:11
@whowes

whowes commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot]
gemini-code-assist Bot reviewed Sep 22, 2026
View reviewed changes

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

Copy link
Copy Markdown
Contributor

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.

Code Review

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ResumableUploadChunkCoordinator.java
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;

@gemini-code-assist gemini-code-assist Bot Sep 22, 2026

Copy link
Copy Markdown
Contributor

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.

high

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.

Suggested change
import com.google.api.gax.rpc.ResumableUploadErrorClassifier.Category;
import com.google.api.gax.rpc.ResumableUploadErrorClassifier.Category;
import org.jspecify.annotations.Nullable;
References
  1. When adopting nullness annotations (such as JSpecify), prioritize adding @Nullable annotations to document nullability, even if doing so temporarily triggers static analysis warnings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@whowes whowes Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

False positive; this import is present in the file as the final import.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ResumableUploadChunkCoordinator.java Outdated
}
}

private void recover() {

@gemini-code-assist gemini-code-assist Bot Sep 22, 2026

Copy link
Copy Markdown
Contributor

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.

high

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@whowes whowes Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 1e2a630 to ca7da1b Compare September 24, 2026 00:45
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from ca7da1b to 4621a6f Compare September 24, 2026 01:07
@whowes
whowes force-pushed the whowes/resumable-upload-recovery branch from 4621a6f to 2bf5fb5 Compare September 24, 2026 05:52
blakeli0
blakeli0 reviewed Sep 24, 2026
View reviewed changes
Comment thread ...-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ResumableUploadChunkCoordinator.java Outdated
"Upload stream ended and final chunk was transmitted, but server returned"
+ " incomplete status"));
if (response.getUploadStatus() == ResumableUploadStatus.UNKNOWN) {
recover();

@blakeli0 blakeli0 Sep 24, 2026

Copy link
Copy Markdown
Contributor

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@whowes whowes Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ResumableUploadChunkCoordinator.java Outdated
"Query status response missing X-Goog-Upload-Status header for upload URL: " + uploadUrl);
}
if (queryResponse.getUploadStatus() == ResumableUploadStatus.FINAL) {
onChunkUploaded(

@blakeli0 blakeli0 Sep 24, 2026

Copy link
Copy Markdown
Contributor

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@whowes whowes Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
blakeli0
blakeli0 approved these changes Sep 25, 2026
View reviewed changes
blakeli0
blakeli0 reviewed Sep 25, 2026
View reviewed changes
Comment thread ...form-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ResumableUploadCallableImpl.java
createRetryingCallable(
client.queryStatusCallable(), ResumableUploadCommand.QUERY, clientContext);
this.recoveryAlgorithm =
new ExponentialRetryAlgorithm(RETRY_SETTINGS, clientContext.getClock());

@blakeli0 blakeli0 Sep 25, 2026

Copy link
Copy Markdown
Contributor

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

whowes reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@whowes
feat(gax): add recoverable error query and buffer realignment loop
f31612c
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.
@sonarqubecloud

sonarqubecloud Bot commented Sep 26, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sonarqubecloud

sonarqubecloud Bot commented Sep 26, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@release-please release-please Bot mentioned this pull request Sep 30, 2026
chore(main): release 1.93.0 #14552
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@blakeli0 blakeli0 blakeli0 approved these changes
+1 more reviewer
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@whowes @blakeli0
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.