bvolpato commented on code in PR #28050:
URL: https://github.com/apache/beam/pull/28050#discussion_r1297705310


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiWritesShardedRecords.java:
##########
@@ -664,21 +664,28 @@ public void process(
             boolean offsetMismatch =
                 statusCode.equals(Code.OUT_OF_RANGE) || 
statusCode.equals(Code.ALREADY_EXISTS);
 
-            // Invalidate the StreamWriter and force a new one to be created.
+            boolean quotaError = statusCode.equals(Code.RESOURCE_EXHAUSTED);
             if (!offsetMismatch) {
               // Don't log errors for expected offset mismatch. These will be 
logged as warnings
               // below.
               LOG.error(
                   "Got error " + failedContext.getError() + " closing " + 
failedContext.streamName);
             }
 
-            // TODO: Only do this on explicit NOT_FOUND errors once BigQuery 
reliably produces them.
             try {
+              // TODO: Only do this on explicit NOT_FOUND errors once BigQuery 
reliably produces
+              // them.
               tryCreateTable.call();
             } catch (Exception e) {
               throw new RuntimeException(e);
             }
-            clearClients.accept(failedContexts);
+
+            if (!quotaError) {
+              // This forces us to close and reopen all gRPC connections to 
Storage API on error,
+              // which empirically
+              // fixes random stuckness issues.
+              clearClients.accept(failedContexts);
+            }

Review Comment:
   What should we do in case the error is `RESOURCE_EXHAUSTED`, but the 
resource in question is connections? (`Exceeds 'Concurrent connections' quota`)
   
   Are those clients healthy / can be reused, or not? I would assume that they 
aren't, but I don't know how the next usage would behave.
   
   It would be great to have a server-side signal from BigQuery client on what 
is recoverable or not, but I believe we don't have anything like that today.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to