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

Remove the PartitionStorage, StateStorage and StateReader abstraction #1878

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

tillrohrmann
Copy link
Contributor

This commit removes the PartitionStorage, StateStorage and StateReader abstraction and replaces them with the PartitionStore. This removes an unnecessary layer of abstraction which is no longer needed.

This fixes #276.

@@ -140,6 +140,7 @@ impl ReadOnlyJournalTable for PartitionStore {
invocation_id: &InvocationId,
journal_index: u32,
) -> Result<Option<JournalEntry>> {
self.assert_partition_key(invocation_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Amazing that those live here now!

@@ -347,20 +182,17 @@ impl<Codec> StateMachine<Codec> {
}
}

pub(crate) struct StateMachineApplyContext<'a, S> {
storage: &'a mut S,
pub(crate) struct StateMachineApplyContext<'a, 'b: 'a> {
Copy link
Contributor

Choose a reason for hiding this comment

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

given we have two lifetimes, maybe give them meaningful names?

Also I'm not so sure you need two lifetimes in this Context struct, isn't this reference going to live as long as the mut borrow to transaction anyway for the usage of this struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need two lifetimes because we need to tell Rust that this exclusive borrow will be shorter than the lifetime of the transaction.

pub(crate) struct StateMachineApplyContext<'a, S> {
storage: &'a mut S,
pub(crate) struct StateMachineApplyContext<'a, 'b: 'a> {
storage: &'a mut PartitionStoreTransaction<'b>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I agree with replacing with the concrete type here. I think it's still useful to use traits in case we wanna test the individual methods with a simple unit test that doesn't require rocksdb (or if we wanna replace the rocksdb impl with an in memory one later, always for testing)

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment for essentially all the rest of the file, I feel we should still keep the trait usages, and just use the Table traits

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 guess we can keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well there was a reason not do it because it is super annoying to add the different tables.

@tillrohrmann
Copy link
Contributor Author

I've reintroduced the generic nature of the StateMachineApplyContext. I am quite doubtful whether this was worth the effort.

Copy link
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

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

LGTM

crates/worker/src/partition/state_machine/mod.rs Outdated Show resolved Hide resolved
crates/worker/src/partition/state_machine/mod.rs Outdated Show resolved Hide resolved
@AhmedSoliman
Copy link
Contributor

I'd be in favor of removing unnecessary generics and only introduce them when needed.

This commit removes the PartitionStorage, StateStorage and StateReader abstraction
and replaces them with the PartitionStore. This removes an unnecessary layer of
abstraction which is no longer needed.

This fixes restatedev#276.
@tillrohrmann
Copy link
Contributor Author

I would leave further clean-up work as follow-ups to this PR.

@tillrohrmann tillrohrmann merged commit c2b013f into restatedev:main Aug 23, 2024
11 checks passed
@tillrohrmann tillrohrmann deleted the issues/276 branch August 23, 2024 13:43
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.

Remove various Reader indirections
3 participants