From 25ae79aa4561fd2441f7ff9c3efb548445de8d7e Mon Sep 17 00:00:00 2001 From: Mina Asham Date: Thu, 27 Jul 2023 12:37:01 +0100 Subject: [PATCH 1/5] fix(bigquery): Make exponential backoff retry second based - Currently these retries are doing retries in milliseconds, which is way too aggressive, the current retry steps are (1ms, 2ms, 4ms, 8ms, 16ms, 32ms, 64ms, 128ms, 256ms, 512ms, 1024ms, ...), it's highly likely the first 7 retries will fail with rate limiting specially in a big workload (specifically this is causing an issue in the Spark bigquery connector), I suspect the exponential retries here were meant to be in seconds (though even if it wasn't meant to, this might be a slightly better approach to reduce the load on the servers - The new steps would be: 1s, 2s, 4s, 8s, 16s, 32s, 60s (repeated till we exhaust the 5 minutes max retries) --- .../google/cloud/bigquery/storage/v1/ConnectionWorker.java | 2 +- .../cloud/bigquery/storage/v1/ConnectionWorkerTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java index 82f2439904..83c8edc1c4 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java @@ -502,7 +502,7 @@ private void maybeWaitForInflightQuota() { @VisibleForTesting static long calculateSleepTimeMilli(long retryCount) { - return Math.min((long) Math.pow(2, retryCount), 60000); + return Math.min((long) Math.pow(2, retryCount) * 1000, 60000); } @VisibleForTesting diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java index e548c2b1b8..b0266adc56 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java @@ -502,8 +502,8 @@ public void testStreamNameMismatch() throws Exception { @Test public void testExponentialBackoff() throws Exception { - assertThat(ConnectionWorker.calculateSleepTimeMilli(0)).isEqualTo(1); - assertThat(ConnectionWorker.calculateSleepTimeMilli(5)).isEqualTo(32); + assertThat(ConnectionWorker.calculateSleepTimeMilli(0)).isEqualTo(1000); + assertThat(ConnectionWorker.calculateSleepTimeMilli(5)).isEqualTo(32000); assertThat(ConnectionWorker.calculateSleepTimeMilli(100)).isEqualTo(60000); } From 241173f5caaf6a968fdfe89131b66c9061fd3733 Mon Sep 17 00:00:00 2001 From: Mina Asham Date: Mon, 31 Jul 2023 22:31:40 +0100 Subject: [PATCH 2/5] Update retry base to 50ms --- .../com/google/cloud/bigquery/storage/v1/ConnectionWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java index 83c8edc1c4..a8fc11c4e8 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java @@ -502,7 +502,7 @@ private void maybeWaitForInflightQuota() { @VisibleForTesting static long calculateSleepTimeMilli(long retryCount) { - return Math.min((long) Math.pow(2, retryCount) * 1000, 60000); + return Math.min((long) Math.pow(2, retryCount) * 50, 60000); } @VisibleForTesting From 6344b266991015b61f002b364785d68659592df4 Mon Sep 17 00:00:00 2001 From: Mina Asham Date: Mon, 31 Jul 2023 22:32:40 +0100 Subject: [PATCH 3/5] Update tests --- .../cloud/bigquery/storage/v1/ConnectionWorkerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java index b0266adc56..9e05e767ce 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java @@ -502,8 +502,8 @@ public void testStreamNameMismatch() throws Exception { @Test public void testExponentialBackoff() throws Exception { - assertThat(ConnectionWorker.calculateSleepTimeMilli(0)).isEqualTo(1000); - assertThat(ConnectionWorker.calculateSleepTimeMilli(5)).isEqualTo(32000); + assertThat(ConnectionWorker.calculateSleepTimeMilli(0)).isEqualTo(50); + assertThat(ConnectionWorker.calculateSleepTimeMilli(5)).isEqualTo(1600); assertThat(ConnectionWorker.calculateSleepTimeMilli(100)).isEqualTo(60000); } From 13b9f1f0d2e50dc8f4034d9b8c154dc05ea69dc5 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 27 Oct 2023 19:07:18 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8d499b88e9..fe0d831c86 100644 --- a/README.md +++ b/README.md @@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.19.0') +implementation platform('com.google.cloud:libraries-bom:26.26.0') implementation 'com.google.cloud:google-cloud-bigquerystorage' ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-bigquerystorage:2.41.0' +implementation 'com.google.cloud:google-cloud-bigquerystorage:2.44.1' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.41.0" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.44.1" ``` @@ -220,7 +220,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquerystorage/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquerystorage.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquerystorage/2.41.0 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquerystorage/2.44.1 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles From 6f967b1b684e5d3f7dffd2caeac644e320b65d83 Mon Sep 17 00:00:00 2001 From: Mina Asham Date: Sat, 28 Oct 2023 12:51:22 +0100 Subject: [PATCH 5/5] Avoid long overflow - Make the comparison happen on the double side then cast to long at the end to avoid overflow happening from the calculation itself - This was actually a bug from before, just wasn't happening because there was no 50 multiplier to get it into that state! --- .../com/google/cloud/bigquery/storage/v1/ConnectionWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java index a8fc11c4e8..1128ac7702 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java @@ -502,7 +502,7 @@ private void maybeWaitForInflightQuota() { @VisibleForTesting static long calculateSleepTimeMilli(long retryCount) { - return Math.min((long) Math.pow(2, retryCount) * 50, 60000); + return (long) Math.min(Math.pow(2, retryCount) * 50, 60000); } @VisibleForTesting