Skip to content

Commit

Permalink
fix: ParallelCompositeUpload in Transfer Manager hangs when encounter…
Browse files Browse the repository at this point in the history
…ing OOM (#2526)

* fix: ParallelCompositeUpload in Transfer Manager hangs when encountering OOM

* lint

* include missing import
  • Loading branch information
sydney-munro authored May 6, 2024
1 parent 7d7f526 commit 67a7c6b
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.BlobWriteSessionConfigs;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.BufferAllocationStrategy;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.ExecutorSupplier;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.Storage.BlobWriteOption;
Expand Down Expand Up @@ -83,7 +84,11 @@ final class TransferManagerImpl implements TransferManager {
if (transferManagerConfig.isAllowParallelCompositeUpload()) {
ParallelCompositeUploadBlobWriteSessionConfig pcuConfig =
BlobWriteSessionConfigs.parallelCompositeUpload()
.withExecutorSupplier(ExecutorSupplier.useExecutor(executor));
.withExecutorSupplier(ExecutorSupplier.useExecutor(executor))
.withBufferAllocationStrategy(
BufferAllocationStrategy.fixedPool(
transferManagerConfig.getMaxWorkers(),
transferManagerConfig.getPerWorkerBufferSize()));
storageOptions = storageOptions.toBuilder().setBlobWriteSessionConfig(pcuConfig).build();
}
this.pcuQueue = new ConcurrentLinkedDeque<>();
Expand Down Expand Up @@ -264,8 +269,13 @@ public void run() {
return;
}

UploadResult result = poll.callable.call();
poll.resultFuture.set(result);
try {
UploadResult result = poll.callable.call();
poll.resultFuture.set(result);
} catch (Throwable e) {
poll.resultFuture.setException(e);
throw e;
}

} while (true);
}
Expand Down

0 comments on commit 67a7c6b

Please sign in to comment.