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

Refactor log_event function and add retry logic #1660

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

G-D-Petrov
Copy link
Collaborator

We will attempt to retry the writing of the op log up to Storage.MaxOpLogWriteRetries times.
This approach is similar to the one already used when loading the ref key

Reference Issues/PRs

What does this implement or fix?

Any other comments?

Checklist

Checklist for code changes...
  • Have you updated the relevant docstrings, documentation and copyright notice?
  • Is this contribution tested against all ArcticDB's features?
  • Do all exceptions introduced raise appropriate error messages?
  • Are API changes highlighted in the PR description?
  • Is the PR labelled as enhancement or bug so it appears in autogenerated release notes?

@jamesmunro
Copy link
Collaborator

Some backoff would be useful. Apart from avoiding extra load when things go wrong it also helps reduce the chance of a retry hitting the same issue. Why not use https://github.com/man-group/ArcticDB/blob/dc6764fb5ef2d159f9f2e35bcf9c68493d94b140/cpp/arcticdb/util/exponential_backoff.hpp ?

SegmentInMemory seg{log_stream_descriptor(action)};
store->write_sync(KeyType::LOG, version_id, StreamId{action}, IndexValue{id}, IndexValue{id}, std::move(seg));
static const auto max_trial_config = ConfigsMap::instance()->get_int("Storage.MaxOpLogWriteRetries", 2);
auto max_trials = max_trial_config;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with James that it would be better to use the ExponentialBackoff that already exists, as this will retry very fast and possible encounter the same error.

@G-D-Petrov G-D-Petrov merged commit cb60722 into master Jul 8, 2024
114 checks passed
@G-D-Petrov G-D-Petrov deleted the retry_logic_for_writing_op_logs branch July 8, 2024 12:36
G-D-Petrov added a commit that referenced this pull request Jul 8, 2024
We will attempt to retry the writing of the op log up to
`Storage.MaxOpLogWriteRetries` times.
This approach is similar to the one already used when [loading the ref
key](https://github.com/man-group/ArcticDB/blob/66a5d19c4a2c3b2423b52a68f984ca8d9b52afce/cpp/arcticdb/version/version_map.hpp#L190)

#### Reference Issues/PRs
<!--Example: Fixes #1234. See also #3456.-->

#### What does this implement or fix?

#### Any other comments?

#### Checklist

<details>
  <summary>
   Checklist for code changes...
  </summary>

- [ ] Have you updated the relevant docstrings, documentation and
copyright notice?
- [ ] Is this contribution tested against [all ArcticDB's
features](../docs/mkdocs/docs/technical/contributing.md)?
- [ ] Do all exceptions introduced raise appropriate [error
messages](https://docs.arcticdb.io/error_messages/)?
 - [ ] Are API changes highlighted in the PR description?
- [ ] Is the PR labelled as enhancement or bug so it appears in
autogenerated release notes?
</details>

<!--
Thanks for contributing a Pull Request to ArcticDB! Please ensure you
have taken a look at:
- ArcticDB's Code of Conduct:
https://github.com/man-group/ArcticDB/blob/master/CODE_OF_CONDUCT.md
- ArcticDB's Contribution Licensing:
https://github.com/man-group/ArcticDB/blob/master/docs/mkdocs/docs/technical/contributing.md#contribution-licensing
-->

(cherry picked from commit cb60722)
G-D-Petrov added a commit that referenced this pull request Jul 9, 2024
We will attempt to retry the writing of the op log up to
`Storage.MaxOpLogWriteRetries` times.
This approach is similar to the one already used when [loading the ref
key](https://github.com/man-group/ArcticDB/blob/66a5d19c4a2c3b2423b52a68f984ca8d9b52afce/cpp/arcticdb/version/version_map.hpp#L190)

#### Reference Issues/PRs
<!--Example: Fixes #1234. See also #3456.-->

#### What does this implement or fix?

#### Any other comments?

#### Checklist

<details>
  <summary>
   Checklist for code changes...
  </summary>

- [ ] Have you updated the relevant docstrings, documentation and
copyright notice?
- [ ] Is this contribution tested against [all ArcticDB's
features](../docs/mkdocs/docs/technical/contributing.md)?
- [ ] Do all exceptions introduced raise appropriate [error
messages](https://docs.arcticdb.io/error_messages/)?
 - [ ] Are API changes highlighted in the PR description?
- [ ] Is the PR labelled as enhancement or bug so it appears in
autogenerated release notes?
</details>

<!--
Thanks for contributing a Pull Request to ArcticDB! Please ensure you
have taken a look at:
- ArcticDB's Code of Conduct:
https://github.com/man-group/ArcticDB/blob/master/CODE_OF_CONDUCT.md
- ArcticDB's Contribution Licensing:
https://github.com/man-group/ArcticDB/blob/master/docs/mkdocs/docs/technical/contributing.md#contribution-licensing
-->

(cherry picked from commit cb60722)

#### Reference Issues/PRs
<!--Example: Fixes #1234. See also #3456.-->

#### What does this implement or fix?

#### Any other comments?

#### Checklist

<details>
  <summary>
   Checklist for code changes...
  </summary>
 
- [ ] Have you updated the relevant docstrings, documentation and
copyright notice?
- [ ] Is this contribution tested against [all ArcticDB's
features](../docs/mkdocs/docs/technical/contributing.md)?
- [ ] Do all exceptions introduced raise appropriate [error
messages](https://docs.arcticdb.io/error_messages/)?
 - [ ] Are API changes highlighted in the PR description?
- [ ] Is the PR labelled as enhancement or bug so it appears in
autogenerated release notes?
</details>

<!--
Thanks for contributing a Pull Request to ArcticDB! Please ensure you
have taken a look at:
- ArcticDB's Code of Conduct:
https://github.com/man-group/ArcticDB/blob/master/CODE_OF_CONDUCT.md
- ArcticDB's Contribution Licensing:
https://github.com/man-group/ArcticDB/blob/master/docs/mkdocs/docs/technical/contributing.md#contribution-licensing
-->

---------

Co-authored-by: Phoebus Mak <61957902+phoebusm@users.noreply.github.com>
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