Skip to content

Commit f2d0474

Browse files
Dhriti07Dhriti Chopra
andauthored
fix(storage): BidiAppendableUpload Takeover operation fixes (#13776)
BidiAppendableUpload Takeover operation fixes Co-authored-by: Dhriti Chopra <dhritichopra@google.com>
1 parent 5fe1356 commit f2d0474

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

java-storage/google-cloud-storage/src/main/java/com/google/cloud/storage/BidiUploadState.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ final void updateStateFromResponse(BidiWriteObjectResponse response) {
544544
if (state == State.INITIALIZING || state == State.RETRYING) {
545545
transitionTo(
546546
stateToReturnToAfterRetry != null ? stateToReturnToAfterRetry : State.RUNNING);
547+
stateToReturnToAfterRetry = null;
547548
}
548549

549550
boolean signalTerminalSuccess = false;
@@ -679,7 +680,9 @@ final void pendingRetry() {
679680
lock.lock();
680681
try {
681682
validateCurrentStateIsOneOf(State.allNonTerminal);
682-
stateToReturnToAfterRetry = state;
683+
if (state != State.RETRYING && state != State.PENDING_RETRY) {
684+
stateToReturnToAfterRetry = state;
685+
}
683686
transitionTo(State.PENDING_RETRY);
684687
} finally {
685688
lock.unlock();
@@ -887,10 +890,11 @@ void awaitState(State... anyOf) throws InterruptedException {
887890
lock.lock();
888891
try {
889892
ImmutableSet<State> states = ImmutableSet.copyOf(anyOf);
890-
while (!states.contains(this.state) && !stateUpdated.await(5, TimeUnit.MILLISECONDS)) {
893+
while (!states.contains(this.state)) {
891894
if (resultFuture.isDone()) {
892895
return;
893896
}
897+
stateUpdated.await(5, TimeUnit.MILLISECONDS);
894898
}
895899
} finally {
896900
lock.unlock();
@@ -913,11 +917,11 @@ public void awaitTakeoverStateReconciliation(Runnable restart) {
913917
public void awaitAck(long writeOffset) throws InterruptedException {
914918
lock.lock();
915919
try {
916-
while (confirmedBytes < writeOffset
917-
&& !confirmedBytesUpdated.await(5, TimeUnit.MILLISECONDS)) {
920+
while (confirmedBytes < writeOffset) {
918921
if (resultFuture.isDone()) {
919922
return;
920923
}
924+
confirmedBytesUpdated.await(5, TimeUnit.MILLISECONDS);
921925
}
922926
} finally {
923927
lock.unlock();

java-storage/google-cloud-storage/src/test/java/com/google/cloud/storage/ITAppendableUploadTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
@RunWith(StorageITRunner.class)
6060
@CrossRun(
61-
backends = {Backend.TEST_BENCH},
61+
backends = {Backend.TEST_BENCH, Backend.PROD},
6262
transports = Transport.GRPC)
6363
@Parameterized(UploadConfigParameters.class)
6464
public final class ITAppendableUploadTest {

java-storage/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/BackendResources.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ static BackendResources of(
259259
protectedBucketNames.add(bucketName);
260260
return new BucketInfoShim(
261261
BucketInfo.newBuilder(bucketName)
262-
.setLocation(zone.get().get().getRegion())
262+
.setLocation("us-central1")
263263
.setCustomPlacementConfig(
264264
CustomPlacementConfig.newBuilder()
265-
.setDataLocations(ImmutableList.of(zone.get().get().getZone()))
265+
.setDataLocations(ImmutableList.of("us-central1-c"))
266266
.build())
267267
.setStorageClass(StorageClass.valueOf("RAPID"))
268268
.setHierarchicalNamespace(

0 commit comments

Comments
 (0)