Skip to content

Commit

Permalink
fix: Modify client lib retry policy for CreateWriteStream with longer…
Browse files Browse the repository at this point in the history
… backoff, more error code and longer overall time (#1679)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 457061436

Source-Link: googleapis/googleapis@8ff130b

Source-Link: https://github.com/googleapis/googleapis-gen/commit/2eb0faca717d9cf44b838b7db5e862451b8a86ef
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmViMGZhY2E3MTdkOWNmNDRiODM4YjdkYjVlODYyNDUxYjhhODZlZiJ9

feat: add fields to eventually contain row level errors
Committer: @gnanda
PiperOrigin-RevId: 456324780

Source-Link: googleapis/googleapis@f24b37a

Source-Link: https://github.com/googleapis/googleapis-gen/commit/33f9d814082117116c4b68a6f5aac3f42bec35c2
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzNmOWQ4MTQwODIxMTcxMTZjNGI2OGE2ZjVhYWMzZjQyYmVjMzVjMiJ9
  • Loading branch information
gcf-owl-bot[bot] authored Jun 27, 2022
1 parent 2821ee9 commit ec3ea29
Show file tree
Hide file tree
Showing 17 changed files with 1,968 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ public BigQueryReadStub getStub() {
* @param maxStreamCount Max initial number of streams. If unset or zero, the server will provide
* a value of streams so as to produce reasonable throughput. Must be non-negative. The number
* of streams may be lower than the requested number, depending on the amount parallelism that
* is reasonable for the table. Error will be returned if the max count is greater than the
* current system max limit of 1,000.
* <p>Streams must be read starting from offset 0.
* is reasonable for the table. There is a default system max limit of 1,000.
* <p>This must be greater than or equal to preferred_min_stream_count. Typically, clients
* should either leave this unset to let the system to determine an upper bound OR set this a
* size for the maximum "units of work" it can gracefully handle.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ReadSession createReadSession(
Expand Down Expand Up @@ -243,9 +244,10 @@ public final ReadSession createReadSession(
* @param maxStreamCount Max initial number of streams. If unset or zero, the server will provide
* a value of streams so as to produce reasonable throughput. Must be non-negative. The number
* of streams may be lower than the requested number, depending on the amount parallelism that
* is reasonable for the table. Error will be returned if the max count is greater than the
* current system max limit of 1,000.
* <p>Streams must be read starting from offset 0.
* is reasonable for the table. There is a default system max limit of 1,000.
* <p>This must be greater than or equal to preferred_min_stream_count. Typically, clients
* should either leave this unset to let the system to determine an upper bound OR set this a
* size for the maximum "units of work" it can gracefully handle.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ReadSession createReadSession(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,20 @@ public static class Builder extends StubSettings.Builder<BigQueryWriteStubSettin
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"retry_policy_4_codes",
"retry_policy_5_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
StatusCode.Code.DEADLINE_EXCEEDED,
StatusCode.Code.UNAVAILABLE,
StatusCode.Code.RESOURCE_EXHAUSTED)));
definitions.put(
"retry_policy_3_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put(
"retry_policy_4_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -260,15 +267,15 @@ public static class Builder extends StubSettings.Builder<BigQueryWriteStubSettin
RetrySettings settings = null;
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setInitialRetryDelay(Duration.ofMillis(10000L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(600000L))
.setMaxRetryDelay(Duration.ofMillis(120000L))
.setInitialRpcTimeout(Duration.ofMillis(1200000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeout(Duration.ofMillis(1200000L))
.setTotalTimeout(Duration.ofMillis(1200000L))
.build();
definitions.put("retry_policy_4_params", settings);
definitions.put("retry_policy_5_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
Expand All @@ -280,6 +287,17 @@ public static class Builder extends StubSettings.Builder<BigQueryWriteStubSettin
.setTotalTimeout(Duration.ofMillis(86400000L))
.build();
definitions.put("retry_policy_3_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(600000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.build();
definitions.put("retry_policy_4_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -342,8 +360,8 @@ private static Builder createDefault() {
private static Builder initDefaults(Builder builder) {
builder
.createWriteStreamSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.getWriteStreamSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ public void createWriteStreamExceptionTest2() throws Exception {
@Test
public void appendRowsTest() throws Exception {
AppendRowsResponse expectedResponse =
AppendRowsResponse.newBuilder().setUpdatedSchema(TableSchema.newBuilder().build()).build();
AppendRowsResponse.newBuilder()
.setUpdatedSchema(TableSchema.newBuilder().build())
.addAllRowErrors(new ArrayList<RowError>())
.build();
mockBigQueryWrite.addResponse(expectedResponse);
AppendRowsRequest request =
AppendRowsRequest.newBuilder()
Expand Down
Loading

0 comments on commit ec3ea29

Please sign in to comment.