Skip to content

Commit

Permalink
Refactor log_event function and add retry logic (#1660)
Browse files Browse the repository at this point in the history
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
-->
  • Loading branch information
G-D-Petrov committed Jul 8, 2024
1 parent dc6764f commit cb60722
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpp/arcticdb/version/version_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ namespace arcticdb {
};

inline void log_event(const std::shared_ptr<StreamSink>& store, const StreamId& id, std::string action, VersionId version_id=0) {
SegmentInMemory seg{log_stream_descriptor(action)};
store->write_sync(KeyType::LOG, version_id, StreamId{action}, IndexValue{id}, IndexValue{id}, std::move(seg));
ExponentialBackoff<StorageException>(100, 2000)
.go([&store, &id, &action, &version_id]() {
SegmentInMemory seg{log_stream_descriptor(action)};
store->write_sync(KeyType::LOG, version_id, StreamId{action}, IndexValue{id}, IndexValue{id}, std::move(seg));
});
}

inline void log_write(const std::shared_ptr<StreamSink>& store, const StreamId& symbol, VersionId version_id) {
Expand Down

0 comments on commit cb60722

Please sign in to comment.