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

add retry mechanism to write_backlog #605

Merged
merged 10 commits into from
Jun 12, 2024

Conversation

dtrai2
Copy link
Collaborator

@dtrai2 dtrai2 commented Jun 11, 2024

No description provided.

@dtrai2 dtrai2 self-assigned this Jun 11, 2024
@dtrai2 dtrai2 marked this pull request as ready for review June 12, 2024 06:50
@dtrai2 dtrai2 requested a review from ekneg54 June 12, 2024 06:50
@dtrai2 dtrai2 added the enhancement New feature or request label Jun 12, 2024
Copy link
Collaborator

@ekneg54 ekneg54 left a comment

Choose a reason for hiding this comment

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

thanks for the contribution. Please have a look for my comments on your implementation

logprep/connector/opensearch/output.py Outdated Show resolved Hide resolved
logprep/connector/opensearch/output.py Outdated Show resolved Hide resolved
Comment on lines 146 to 161
def _parallel_bulk_with_retries(self, client, actions, *args, **kwargs):
bulk_delays = 1
for _ in range(self._config.bulk_retries):
try:
self._parallel_bulk(actions, client, *args, **kwargs)
return
except search.ConnectionError as error:
raise error
except search.exceptions.TransportError as error:
if self._message_exceeds_max_size_error(error):
raise error
time.sleep(bulk_delays)
bulk_delays += random.randint(500, 1000) / 1000
raise FatalOutputError(
self, "Opensearch too many requests, all parallel bulk retries failed"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of writing this new method, how about extending the called method and add the max_retries parameter to the signature and use it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

well I implemented it as a second method to reduce nesting. I reverted it now, please have a look at it and let me know which version you like more: (a) all in one method or (b) split up into two methods.

@dtrai2 dtrai2 requested a review from ekneg54 June 12, 2024 12:44
Copy link
Collaborator

@ekneg54 ekneg54 left a comment

Choose a reason for hiding this comment

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

one last thing 🥇

logprep/connector/opensearch/output.py Outdated Show resolved Hide resolved
@dtrai2 dtrai2 requested a review from ekneg54 June 12, 2024 13:35
@ekneg54 ekneg54 merged commit 4887391 into main Jun 12, 2024
9 checks passed
@ekneg54 ekneg54 deleted the dev-implement-retry-mechanism-to--write-backlog branch June 12, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants