Github user hsaputra commented on a diff in the pull request:

    https://github.com/apache/twill/pull/23#discussion_r99416151
  
    --- Diff: 
twill-yarn/src/main/java/org/apache/twill/internal/appmaster/RunningContainers.java
 ---
    @@ -477,10 +493,30 @@ void handleCompleted(YarnContainerStatus status, 
Multiset<String> restartRunnabl
         }
       }
     
    -  private boolean shouldRetry(int exitCode) {
    -    return exitCode != ContainerExitCodes.SUCCESS
    -      && exitCode != ContainerExitCodes.DISKS_FAILED
    -      && exitCode != ContainerExitCodes.INIT_FAILED;
    +  private boolean shouldRetry(String runnableName, int instanceId, int 
exitCode) {
    +    boolean possiblyRetry = 
    +        exitCode != ContainerExitCodes.SUCCESS && 
    +        exitCode != ContainerExitCodes.DISKS_FAILED && 
    +        exitCode != ContainerExitCodes.INIT_FAILED;
    +    
    +    if (possiblyRetry) {
    +      int max = getMaxRetries(runnableName);
    +      if (max == Integer.MAX_VALUE) {
    +        return true; // retry without special log msg
    +      }
    +
    +      if (getRetryCount(runnableName, instanceId) == max) {
    --- End diff --
    
    Since we call `getRetryCount` for this check, might as well cache it as 
local var to make sure we got  the right one for this request:
    
    ```
    int retryCount = getRetryCount(runnableName, instanceId);
    if (getRetryCount(runnableName, instanceId) == max) {
      ...
    } else {
      LOG.info("Attempting {} of {} retries for instance {} of runnable {}.", 
retryCount + 1,
        max, instanceId, runnableName);
      return true;
    }
    ```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to