Skip to content

Conversation

BenWhitehead
Copy link
Collaborator

When finalizing an appendable upload depending on how quickly gcs is acking bytes, we could run into a case where finish_write: true was sent before all bytes had been enqueued.

Regression introduced in 2.57.0

When finalizing an appendable upload depending on how quickly
gcs is acking bytes, we could run into a case where finish_write: true
was sent before all bytes had been enqueued.

Regression introduced in 2.57.0
@BenWhitehead BenWhitehead requested a review from a team as a code owner September 16, 2025 19:09
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. labels Sep 16, 2025
if (i < lastIdx && !shouldFlush) {
appended = stream.append(datum);
} else if (i == lastIdx && nextWriteShouldFinalize) {
} else if (i == lastIdx && remainingAfterPacking == 0 && nextWriteShouldFinalize) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These two lines are the actual fix

totalSentBytes,
confirmedBytes,
size
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding more info to the diagnostic to make it more useful in the future.

@Rule public final TestName testName = new TestName();

@Test
public void appendAndFinalizeOnlyPerformedIfAllBytesConsumed() throws IOException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The new test to verify the fix

}
}

private static BidiStreamingCallable<BidiWriteObjectRequest, BidiWriteObjectResponse>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved into BidiUploadTestUtils.java for sharing

@danielduhh
Copy link
Contributor

Was this caught somewhere? Is there a bug with context?

@BenWhitehead
Copy link
Collaborator Author

Was this caught somewhere? Is there a bug with context?

b/445496061

Copy link
Contributor

@ddelgrosso1 ddelgrosso1 left a comment

Choose a reason for hiding this comment

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

LGTM. Sync'd with Ben earlier / was discussed in biweekly.

@BenWhitehead BenWhitehead merged commit 485be18 into main Sep 16, 2025
25 checks passed
@BenWhitehead BenWhitehead deleted the fix/appendable/finalize-race branch September 16, 2025 21:17
nidhiii-27 pushed a commit to nidhiii-27/java-storage that referenced this pull request Oct 6, 2025
When finalizing an appendable upload depending on how quickly
gcs is acking bytes, we could run into a case where finish_write: true
was sent before all bytes had been enqueued.

Regression introduced in 2.57.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants