Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not retry some exceptions #231

Merged
merged 14 commits into from
Jul 8, 2024
Merged

Do not retry some exceptions #231

merged 14 commits into from
Jul 8, 2024

Conversation

sonus21
Copy link
Owner

@sonus21 sonus21 commented Jul 2, 2024

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit Test
  • Integration Test
  • Reactive Integration Test

Test Configuration:

  • Spring Version
  • Spring Boot Version
  • Redis Driver Version

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@coveralls
Copy link

coveralls commented Jul 2, 2024

Pull Request Test Coverage Report for Build 2777

Details

  • 31 of 36 (86.11%) changed or added relevant lines in 8 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 91.612%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/PostProcessingHandler.java 5 6 83.33%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/RqueueExecutor.java 12 13 92.31%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/DefaultRqueuePoller.java 8 11 72.73%
Files with Coverage Reduction New Missed Lines %
rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/RqueueMessageTemplateImpl.java 1 95.45%
rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/MessageSweeper.java 2 95.7%
Totals Coverage Status
Change from base Build 2768: 0.2%
Covered Lines: 5406
Relevant Lines: 5901

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 2784

Details

  • 32 of 40 (80.0%) changed or added relevant lines in 10 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 91.592%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/PostProcessingHandler.java 5 6 83.33%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/RqueueExecutor.java 12 13 92.31%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/StrictPriorityPoller.java 0 1 0.0%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/WeightedPriorityPoller.java 0 1 0.0%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/DefaultRqueuePoller.java 9 13 69.23%
Files with Coverage Reduction New Missed Lines %
rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/RqueueMessageTemplateImpl.java 1 95.45%
rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/MessageSweeper.java 2 95.7%
Totals Coverage Status
Change from base Build 2768: 0.2%
Covered Lines: 5403
Relevant Lines: 5899

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 2794

Details

  • 39 of 48 (81.25%) changed or added relevant lines in 10 files are covered.
  • 4 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.07%) to 91.353%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/PostProcessingHandler.java 5 6 83.33%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/StrictPriorityPoller.java 0 1 0.0%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/WeightedPriorityPoller.java 0 1 0.0%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/RqueueExecutor.java 19 21 90.48%
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/DefaultRqueuePoller.java 9 13 69.23%
Files with Coverage Reduction New Missed Lines %
rqueue-core/src/main/java/com/github/sonus21/rqueue/listener/RqueueExecutor.java 1 89.3%
rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/RqueueMessageTemplateImpl.java 1 95.45%
rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/MessageSweeper.java 2 95.7%
Totals Coverage Status
Change from base Build 2768: -0.07%
Covered Lines: 5388
Relevant Lines: 5898

💛 - Coveralls

boolean doNoRetry = Objects.nonNull(exceptions) &&
!exceptions.isEmpty() &&
Objects.nonNull(error) &&
exceptions.contains(error.getClass());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this? I think error.getClass() will always be a MessagingException - its cause will be the real exception (e.g. DoNotRetry2Exception)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, fixing this then causes the test to BootDoNotRetryTest to fail.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, it's a bit more complicated:

If an exception is thrown in the handler, it will be wrapped by a MessagingException, and we have to check if error.getCause().getClass() is in the set of exceptions.

If an exception is thrown in middleware, then it will not (necessarily) be a MessagingException.

I could live with throwing (or re-throwing) only in the middleware, but I'm not sure if this is a good expectation.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, you're right. In such cases we can check two things if it contains the actual class or it contains the cause. That should work, let me know if you think otherwise

class BootDoNotRetryTest extends RetryTests {

@Test
void taskIsNotRetried() throws TimedOutException {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this test is correct:
Even though the job throws a DoNotRetryException exception, I can see that the job is being executed several (I think 4) times.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me investigate this, not sure how did it pass. It should have failed

@@ -270,18 +274,19 @@ private int getMaxRetryCount(RqueueMessage rqueueMessage, QueueDetail queueDetai
: rqueueMessage.getRetryCount();
}

private void handleFailure(JobImpl job, int failureCount) {
private void handleFailure(JobImpl job, int failureCount, Throwable throwable) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to check for getDoNotRetry() classes here too?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need here as this is just to get the stop flag for backoff method

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we need that here too, my bad.

@sonus21 sonus21 changed the title Do not retry Do not retry some exceptions Jul 8, 2024
@sonus21 sonus21 merged commit 6baf574 into master Jul 8, 2024
3 of 7 checks passed
@sonus21 sonus21 mentioned this pull request Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants