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

#447 Exception normalization for RocksDB #1360

Merged
merged 5 commits into from
Feb 28, 2024

Conversation

muhammadhamzasajjad
Copy link
Collaborator

This PR performs normalization of RocksDB storage exceptions as per #584.

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?

@muhammadhamzasajjad muhammadhamzasajjad force-pushed the rocksdb_storage_exceptions branch 2 times, most recently from eff3300 to c364fe8 Compare February 26, 2024 17:53
@muhammadhamzasajjad muhammadhamzasajjad requested review from poodlewars and joe-iddon and removed request for poodlewars February 27, 2024 12:09
@muhammadhamzasajjad muhammadhamzasajjad marked this pull request as ready for review February 27, 2024 12:09
@muhammadhamzasajjad muhammadhamzasajjad self-assigned this Feb 27, 2024
Copy link
Collaborator

@poodlewars poodlewars left a comment

Choose a reason for hiding this comment

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

Happy for this to be merged once Joe's comment about logging is fixed

log::storage().debug("Failed to read segment for key {}", variant_key_view(k));
failed_reads.push_back(k);
}
else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

(nit) we usually have the else on the line above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 9fed291.

@@ -125,10 +126,18 @@ void RocksDBStorage::do_read(Composite<VariantKey>&& ks, const ReadVisitor& visi
std::string k_str = to_serialized_key(k);
std::string value;
auto s = db_->Get(::rocksdb::ReadOptions(), handle, ::rocksdb::Slice(k_str), &value);
util::check(s.ok(), DEFAULT_ROCKSDB_NOT_OK_ERROR + s.ToString());
visitor(k, Segment::from_bytes(reinterpret_cast<uint8_t*>(value.data()), value.size()));
storage::check<ErrorCode::E_UNEXPECTED_ROCKSDB_ERROR>(s.IsNotFound() || s.ok(), DEFAULT_ROCKSDB_NOT_OK_ERROR + s.ToString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see OK, so this is where we could extend the error handling later to handle additional statuses from https://github.com/facebook/rocksdb/blob/main/include/rocksdb/status.h

Copy link
Collaborator

@poodlewars poodlewars left a comment

Choose a reason for hiding this comment

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

Looks good! Please squash the commits when you merge

@muhammadhamzasajjad muhammadhamzasajjad merged commit 8db4515 into master Feb 28, 2024
110 checks passed
@muhammadhamzasajjad muhammadhamzasajjad deleted the rocksdb_storage_exceptions branch February 28, 2024 10:27
muhammadhamzasajjad added a commit that referenced this pull request Mar 14, 2024
This is the final PR for exception normalization. Previous PRs are
#1411, #1360, #1344, #1304, #1297 and #1285
#### Reference Issues/PRs
Previously #1285 only normalized `KeyNotFoundException` and
`DuplicateKeyException` correctly. As mentioned in [this
comment](#1285 (comment)),
we need to normalize other lmdb specific errors too. This PR does that.
A mock client is also created to simulate the lmdb errors which aren't
easily produce-able with real lmdb but can occur.

The ErrorCode list has been updated in `error_code.hpp`. Previously, all
the storage error codes were just sequential. This required that each
time a new error was added for a specific storage, all the other error
codes needed to be changed as we want to assign sequential error codes
to the same storage. We now leave 10 error codes for each storage which
allows us to easily add new error codes for a storage without having to
change all the others.

`::lmdb::map_full_error` is now normalized. When this error occurs, lmdb
throws `LMDBMapFullException` which is child of `StorageException`

#### 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
-->
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.

Use specific exception type for certain kinds of storage failures
3 participants