Skip to content

Correctly retry HTTP downloads after incomplete reads#1578

Merged
pquentin merged 3 commits into
elastic:masterfrom
pquentin:incomplete-downloads
Sep 14, 2022
Merged

Correctly retry HTTP downloads after incomplete reads#1578
pquentin merged 3 commits into
elastic:masterfrom
pquentin:incomplete-downloads

Conversation

@pquentin
Copy link
Copy Markdown
Member

The previous change only helped urllib3 notice incomplete reads, but it could not retry given this was a streaming download. This commits implements the actual retries.

The [previous change] only helped urllib3 *notice* incomplete reads, but
it could not retry given this was a streaming download. This commits
implements the actual retries.

[previous change]: elastic#1504
@pquentin pquentin added bug Something's wrong :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc. labels Sep 13, 2022
@pquentin pquentin added this to the 2.6.1 milestone Sep 13, 2022
@pquentin pquentin self-assigned this Sep 13, 2022
@pquentin pquentin changed the title Retry HTTP downloads after incomplete reads Correctly retry HTTP downloads after incomplete reads Sep 13, 2022
@pquentin
Copy link
Copy Markdown
Member Author

@elasticmachine run rally/rally-tracks-compat please

Copy link
Copy Markdown
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

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

Looking forward to this stability improvement. Left a question.

Comment thread esrally/utils/net.py
except urllib3.exceptions.ProtocolError as exc:
if i == HTTP_DOWNLOAD_RETRIES:
raise
logger.warning("Retrying after %s", exc)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we have a delay in between retries? Alternatively we could consider using something like https://pypi.org/project/tenacity/?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I considered introducing a new dependency but thought this was not needed. I did not introduce a delay because I only saw connectivity issues (connection reset, incomplete reads) and not because the server was overloaded. Maybe a simple 1 second sleep could be enough?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed on a simple sleep; I'd go for 5s, but up to you.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, please take another look.

Copy link
Copy Markdown
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread esrally/utils/net.py

def download_http(url, local_path, expected_size_in_bytes=None, progress_indicator=None, *, sleep=time.sleep):
logger = logging.getLogger(__name__)
for i in range(HTTP_DOWNLOAD_RETRIES + 1):

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For reference, the reason is that range(10) would only do 9 retries (1 try + 9 retries).

@pquentin pquentin merged commit aa6ccb8 into elastic:master Sep 14, 2022
@pquentin pquentin deleted the incomplete-downloads branch February 16, 2023 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something's wrong :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants