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

Notimplemented handling #2108

Merged
merged 6 commits into from
Jan 14, 2025
Merged

Notimplemented handling #2108

merged 6 commits into from
Jan 14, 2025

Conversation

G-D-Petrov
Copy link
Collaborator

Reference Issues/PRs

#203 in enterprise

What does this implement or fix?

Add a way to differentiate between a NotImplemented error and a regular StorageException.
This way we can properly handle S3 storages that haven't implemented the write_if_none operation.
Also updated the ReliableStorageLock to use the new behaviour.

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?

@@ -36,7 +36,7 @@ class NfsBackedStorage final : public Storage {
void do_write(Composite<KeySegmentPair>&& kvs) final;

void do_write_if_none(KeySegmentPair&& kv [[maybe_unused]]) final {
storage::raise<ErrorCode::E_UNSUPPORTED_ATOMIC_OPERATION>("Atomic operations are only supported for s3 backend");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The changes for NFS backed storages were made to make testing easier and to add the same general behavior as for S3 storages.
This can be reverted, if needed.

@@ -74,6 +74,10 @@ namespace s3 {
raise<ErrorCode::E_ATOMIC_OPERATION_FAILED>(fmt::format("Atomic operation failed: {}", error_message_suffix));
}

if(err.GetExceptionName().find("NotImplemented") != std::string::npos) {
Copy link
Collaborator

@poodlewars poodlewars Jan 8, 2025

Choose a reason for hiding this comment

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

I assume there's no more robust way to figure this out? Not enough info in the type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The type of the error is UNKNOWN(100) is a but of a catch-all and might result in false positives.
I prefer to handle only this particular case.

@@ -54,7 +54,7 @@ class NfsBackedStorage final : public Storage {
}

bool do_supports_atomic_writes() const final {
return false;
return true;
Copy link
Collaborator

@poodlewars poodlewars Jan 8, 2025

Choose a reason for hiding this comment

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

This should still be false shouldn't it? Is this to make the testing easier like you mention above? I think it's too confusing having this true and then always blowing up when this backend does an atomic write.

Should be possible to test with some extensions to the mocked storages stuff used for the storages C++ tests?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't change those before I merge the storage refactor, it will make a huge amount of work for me.

I was considering getting rid of write_if_none in favour of having it as an option to the write method, as the API is getting quite crowded

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a way to configure this.
Having the ability to enable these writes for the nfs storage makes it easy to write an integration test for the ReliableLock in the enterprise repo

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.

Needs tests.

I think this looks sensible. I discussed with Ivo that we should perhaps add some logic to test a conditional write by actually writing an object to the backend, as the different S3 providers implement this very differently. But we'll probably want this logic anyway.

@G-D-Petrov G-D-Petrov force-pushed the notimplemented_handling branch from af30193 to b18b325 Compare January 13, 2025 07:50
@@ -86,6 +86,7 @@ inline std::unordered_map<ErrorCategory, const char*> get_error_category_names()
ERROR_CODE(5020, E_UNEXPECTED_S3_ERROR) \
ERROR_CODE(5021, E_S3_RETRYABLE) \
ERROR_CODE(5022, E_ATOMIC_OPERATION_FAILED) \
ERROR_CODE(5023, E_NOT_IMPLEMENTED) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This sounds a bit like something that we did not implement yet. It's more that the storage (PURE) does not support it.
What do you think about E_NOT_IMPLEMENTED_BY_STORAGE or E_NOT_SUPPORTED_BY_STORAGE?

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.

Let's implement Ivo's idea #2108 (comment) or we will never remember to come back and do it. Otherwise LGTM

@G-D-Petrov G-D-Petrov merged commit e3b5f53 into master Jan 14, 2025
122 checks passed
@G-D-Petrov G-D-Petrov deleted the notimplemented_handling branch January 14, 2025 15:32
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.

4 participants