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

Eliminate the DatabaseConsistencyError. #2557

Merged

Conversation

MathieuDutSik
Copy link
Contributor

@MathieuDutSik MathieuDutSik commented Oct 1, 2024

Motivation

The DatabaseConsistencyError is a type that if objectively a leaky abstraction. This addresses #2536

Proposal

Several changes are made:

  • The code for store in common.rs is moved to a newly created store.rs.
  • The DatabaseConsistencyError is eliminated.
  • Instead a composite type ValueSplittingError is introduced.

Test Plan

As it is purely a refactoring, only the CI should be affected. Performance should remain strictly
identical.

Release Plan

Not relevant.

Links

None

@MathieuDutSik MathieuDutSik changed the title Eliminate the DatabseConsistencyError. Eliminate the DatabaseConsistencyError. Oct 1, 2024
@MathieuDutSik MathieuDutSik force-pushed the database_consistency_error branch 2 times, most recently from 4c7a3f0 to bff8379 Compare October 2, 2024 13:22
@MathieuDutSik MathieuDutSik marked this pull request as ready for review October 3, 2024 06:07
* Separate the code for the store into a store.rs file.
* Move the MIN_TAG_VIEW to the views.
* Eliminate the DatabaseConsistencyError.
* Avoid the abstraction leakage.
@@ -729,8 +727,7 @@ where
impl<Store> DbStorage<Store, WallClock>
where
Store: KeyValueStore + Clone + Send + Sync + 'static,
Store::Error:
From<bcs::Error> + From<DatabaseConsistencyError> + Send + Sync + serde::ser::StdError,
Store::Error: Send + Sync + serde::ser::StdError,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not from this PR but why are we using serde::ser::StdError? (an alias std::error::Error)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know. I addressed this is in another branch (not yet PR) on the dual store. The answer is that it is not needed.
Let me do this cleanup in this PR.

@@ -221,7 +235,7 @@ where
impl<K> WritableKeyValueStore for ValueSplittingStore<K>
where
K: RestrictedKeyValueStore + Send + Sync,
K::Error: From<bcs::Error> + From<DatabaseConsistencyError>,
K::Error: 'static,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this 'static needed? (also below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor

@ma2bd ma2bd left a comment

Choose a reason for hiding this comment

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

Thanks. Some minor comments but otherwise LGTM

linera-views/src/backends/value_splitting.rs Outdated Show resolved Hide resolved
let len = key.len();
if len < 4 {
return Err(DatabaseConsistencyError::TooShortKey.into());
return Err(ValueSplittingError::<K::Error>::TooShortKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

ValueSplittingError::TooShortKey should be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

@MathieuDutSik MathieuDutSik merged commit 7ff558d into linera-io:main Oct 4, 2024
6 checks passed
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.

2 participants