[ 
https://issues.apache.org/jira/browse/GOBBLIN-1101?focusedWorklogId=412722&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-412722
 ]

ASF GitHub Bot logged work on GOBBLIN-1101:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 31/Mar/20 00:56
            Start Date: 31/Mar/20 00:56
    Worklog Time Spent: 10m 
      Work Description: arekusuri commented on pull request #2942: 
GOBBLIN-1101(DSS-25241): Enhance bulk api retry for ExceedQuota
URL: https://github.com/apache/incubator-gobblin/pull/2942#discussion_r400580522
 
 

 ##########
 File path: 
gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/BulkResultIterator.java
 ##########
 @@ -62,24 +65,51 @@ private void initHeader() {
   }
 
   private List<String> nextLineWithRetry() {
-    Exception exception = null;
-    for (int i = 0; i < retryLimit; i++) {
+    Throwable rootCause = null;
+    int executeCount = 0;
+    while (executeCount < retryLimit + 1) {
+      executeCount ++;
       try {
         if (this.csvReader == null) {
-          this.csvReader = openAndSeekCsvReader(null);
+          this.csvReader = openAndSeekCsvReader(rootCause);
         }
         List<String> line = this.csvReader.nextRecord();
         this.lineCount++;
         return line;
       } catch (InputStreamCSVReader.CSVParseException e) {
         throw new RuntimeException(e); // don't retry if it is parse error
-      } catch (Exception e) { // if it is any other exception, retry may 
resolve the issue.
-        exception = e;
-        log.info("***Retrying***: {} - {}", fileIdVO, e.getMessage());
-        this.csvReader = openAndSeekCsvReader(e);
+      } catch (OpenAndSeekException e) {
+        rootCause = e.getCause();
+        // Each organization is allowed 10 concurrent long-running requests. 
If the limit is reached,
+        // any new synchronous Apex request results in a runtime exception.
+        if (e.isCurrentExceptionExceedQuta()) {
+          log.warn("--Caught ExceededQuota: " + e.getMessage());
+          threadSleep(5 * 60 * 1000); // 5 minutes
+          executeCount --; // if the current exception is Quota Exceeded, keep 
trying forever
+        }
+        log.info("***Retrying***1: {} - {}", fileIdVO, e.getMessage());
+        this.csvReader = null; // in next loop, call openAndSeekCsvReader
+      } catch (Exception e) {
+        // Retry may resolve other exceptions.
+        rootCause = e;
+        threadSleep(1 * 60 * 1000); // 1 minute
 
 Review comment:
   This is meant to be random duration as well. 
   This kind of failure will be retried only limited times. 
   User wouldn't know how long to set up. 
   Only way to find a better duration is test and get an optimal value. However 
this is not a critical value. we don't have to really find out the most optimal 
value.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 412722)
    Time Spent: 1.5h  (was: 1h 20m)

> Enhance bulk api retry for ExceedQuota
> --------------------------------------
>
>                 Key: GOBBLIN-1101
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1101
>             Project: Apache Gobblin
>          Issue Type: Bug
>            Reporter: Alex Li
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> 1. ExceedQuota exception
> Below is SFDC doc about ExceedQuota
> {code:java}
> One of the limits customers frequently reach is the concurrent request limit. 
> Once a synchronous Apex request runs longer than 5 seconds, it begins 
> counting against this limit. Each organization is allowed 10 concurrent 
> long-running requests. If the limit is reached, any new synchronous Apex 
> request results in a runtime exception. This behavior occurs until the 
> organization’s requests are below the limit.
> {code}
> If the ExceedQuota exception happens, we should let the thread sleep 5 
> minutes and try again. There should not be a retryLimit for this exception.
> 2. Except stack in log file
> For example we set up retryLimit to 10, we retried 10 times,  and failed; we 
> need to print out exception stack in log file, there are 10 of them in the 
> exception stack.
> SSL Exception(root cause) ----retry and get ----> ExceedQuota ----retry and 
> get ---->  ExceedQuota ----....a lot........ ----> 
> We'd better skip all the retry exception, only keep the root cause exception.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to