Skip to content

Conversation

@pujagani
Copy link
Contributor

@pujagani pujagani commented Dec 17, 2020

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Related to #8167. Add retry mechanism using Failsafe.

Motivation and Context

When a client makes a request to the server, it might not get fulfilled due to different errors. One category of errors is transient in nature. In such cases, the request might be fulfilled if it is reattempted with a delay. The changes introduce a retry mechanism as a filter. The retry policies handler read timeout, connection failures and server errors (server unavailable and internal server error without response body). Rest of the failures are not retried.

Types of changes

  • 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 change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@pujagani pujagani force-pushed the retry_transient_errors branch from 690ad60 to 912b0ec Compare December 17, 2020 09:41
@sonarqubecloud
Copy link

size = "small",
srcs = glob(["*.java"]),
srcs = glob(["*.java"],
exclude = MEDIUM_TESTS),
Copy link
Member

Choose a reason for hiding this comment

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

Unless buildifier reformatted things this way, it's fine to put the exclude on the same line

e.getAttemptCount()));

// Retry if server is unavailable or an internal server error occurs without response body.
private static final RetryPolicy<HttpResponse> serverErrorPolicy =
Copy link
Member

Choose a reason for hiding this comment

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

I'd be tempted to abandon hope if the response is an internal error: it's likely sending the request again will cause the same problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here the retry is for 500 error code without any response payload. In this iteration, the retry is 2 attempts then results in failure if the error still exists. I am thinking it should be okay. What do you suggest?

@barancev barancev added the C-java Java Bindings label Jan 24, 2021
@pujagani pujagani force-pushed the retry_transient_errors branch from 912b0ec to a224c3a Compare January 25, 2021 06:20
@sonarqubecloud
Copy link

@pujagani pujagani force-pushed the retry_transient_errors branch from 8358831 to 412445d Compare March 26, 2021 10:29
@sonarqubecloud
Copy link

@pujagani pujagani force-pushed the retry_transient_errors branch from 412445d to 9be85e2 Compare October 25, 2021 12:35
// Retry if server is unavailable or an internal server error occurs without response body.
private static final RetryPolicy<HttpResponse> serverErrorPolicy =
new RetryPolicy<HttpResponse>()
.handleResultIf(response -> response.getStatus() == HTTP_INTERNAL_ERROR &&
Copy link
Member

Choose a reason for hiding this comment

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

The webdriver spec uses the 500 response for error responses, so this might be risky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here the retry is for 500 error code without any response payload. In this iteration, the retry is 2 attempts then results in failure if the error still exists. I am thinking it should be okay. What do you suggest?

Copy link
Member

Choose a reason for hiding this comment

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

Let's ship it and see what breaks. I can't think of a circumstance when the remote end will send a 500 without a message body.

@pujagani pujagani force-pushed the retry_transient_errors branch from 45c316f to 3d73887 Compare October 26, 2021 09:59
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@shs96c shs96c left a comment

Choose a reason for hiding this comment

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

Ship it! :)

// Retry if server is unavailable or an internal server error occurs without response body.
private static final RetryPolicy<HttpResponse> serverErrorPolicy =
new RetryPolicy<HttpResponse>()
.handleResultIf(response -> response.getStatus() == HTTP_INTERNAL_ERROR &&
Copy link
Member

Choose a reason for hiding this comment

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

Let's ship it and see what breaks. I can't think of a circumstance when the remote end will send a 500 without a message body.

@pujagani pujagani merged commit f841c48 into SeleniumHQ:trunk Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-java Java Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants