Results 1 to 5 of 5

Thread: weird retry behavior when max retries have been reached

  1. #1

    Default weird retry behavior when max retries have been reached

    I have a very simple job with a commit interval of 2 and a retry policy that we should try maximum 3 times before failing the execution.

    We have built a stat system that reports precisely what's happening in every piece of the step so that we can assert things in our unit tests.

    Say that the job is handling a chunk and the second item (2/2) of the chunk always fails. Here's the statistics that we got:

    Item 1: Read 1, Processed 4, Written 0, Read Error 0, Processed Error 0, Writer error 0
    Item 2: Read 1, Processed 3, Written 0, Reade Error 0, Processed Error 3, Writer error 0

    Why does spring batch tries to process the chunk the 4th times? When the max retries has been reached when processing the chunk for the 3rd time, why don't we stop at this point?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Looks like maybe the exception was skipped and item 1 was processed successfully after the skip? What's your skip limit for that exception type?

  3. #3

    Default

    Quote Originally Posted by Dave Syer View Post
    Looks like maybe the exception was skipped and item 1 was processed successfully after the skip? What's your skip limit for that exception type?
    3. It's in my original message or are you asking for something else? The item that always fail is item2. Item 1 always succeed.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    I re-read your first post (in this thread), and don't see anything that mentions skip, only retry.

  5. #5

    Default

    Code:
        public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException {
            final int maximum = manager.getMaxNumberIgnoredExceptions();
            if (skipCount == maximum) {
                logger.debug("Skip count reached: " + maximum);
                throw new SkipLimitExceededException(maximum, t);
            } else {
                BatchExceptionType type = manager.getExceptionType(t);
                switch (type) {
                    case FATAL_EXCEPTION:
                        logger.debug("It's fatal, so NO SKIP. Skip count = " + skipCount + ". Maximum items skipped= " + maximum);
                        return false;
    
                    case NON_IGNORABLE_EXCEPTION:
                        logger.debug("It's non ignorable, so NO SKIP. Skip count = " + skipCount + ". Maximum items skipped= " + maximum);
                        return false;
    
                    case IGNORABLE_EXCEPTION:
                        logger.debug("It's ignorable, so SKIP. Skip count = " + skipCount + ". Maximum items skipped= " + maximum);
                        return true;
    
                    default:
                        throw new RuntimeException("Exception type not recognized : " + type);
                }
            }
        }
    The skip limit i.e., getMaxNumberIgnoredExceptions() is set by default to 50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •