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

Initial metadata store trait specification #1288

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

tillrohrmann
Copy link
Contributor

Initial metadata store trait specification

Copy link
Contributor

@AhmedSoliman AhmedSoliman left a comment

Choose a reason for hiding this comment

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

Looks neat. I'm curious to know your plan on how will we manage putting the version value in (and out) of the metadata value itself (e.g. nodes_config's version(), etc.)

crates/metadata-store/Cargo.toml Outdated Show resolved Hide resolved
crates/metadata-store/src/lib.rs Outdated Show resolved Hide resolved
crates/metadata-store/src/lib.rs Outdated Show resolved Hide resolved
/// Metadata store abstraction. The metadata store implementations need to support linearizable
/// reads and atomic compare and swap operations.
#[async_trait]
pub trait MetadataStore: Send + Sync {
Copy link
Contributor

Choose a reason for hiding this comment

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

We might also need a set() that always overwrites (accepts a key, value, version) for admin operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed if the version of the payload is the version of the stored key-value pair, right? In case we separate those two, put w/o a precondition could probably already work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was assuming that we'd want to keep them in sync, no? What's the motivation for maintaining two versions?

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 think it would only make sense to have two versions if we wanted to store values that don't have an inherent version. At the moment, I think all our metadata is versioned so it does not make sense for the metadata. Will the cluster controller store state that is not versioned (like the latest plan how to split and move partitions)? If this is not needed, then I could change the trait to take a Versioned + Serialize value.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming that everything will be versioned, but even if not, wouldn't a set() API work for those (assuming that they'd always use a fixed version)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, does the trait itself need to be Send+Sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, does the trait itself need to be Send+Sync?

You are right, it is not needed.

I'm assuming that everything will be versioned, but even if not, wouldn't a set() API work for those (assuming that they'd always use a fixed version)?

If the value would use a fixed version then it will become harder to tell what is the valid value if there are two writers (e.g. 2 cluster controllers that try to do contradicting operations). But I guess the answer would then be to add an explicit version to all state that is stored in the MetadataStore.

crates/metadata-store/src/lib.rs Show resolved Hide resolved
@tillrohrmann
Copy link
Contributor Author

Looks neat. I'm curious to know your plan on how will we manage putting the version value in (and out) of the metadata value itself (e.g. nodes_config's version(), etc.)

So far I was thinking of treating the version of the metadata store key-value pair independent of the version of a potentially versioned value (e.g. nodes configuration, schema information, etc.). This adds a bit more metadata and I guess slightly more complex client-side implementation. On the other hand, it does not require that values that are being stored have a version themselves.

@AhmedSoliman
Copy link
Contributor

So far I was thinking of treating the version of the metadata store key-value pair independent of the version of a potentially versioned value (e.g. nodes configuration, schema information, etc.). This adds a bit more metadata and I guess slightly more complex client-side implementation. On the other hand, it does not require that values that are being stored have a version themselves.

It should be possible to synchronize both copies of the version, but this means an implicit assumption that metadata store will always return the version+1, right?

@tillrohrmann
Copy link
Contributor Author

tillrohrmann commented Mar 19, 2024

It should be possible to synchronize both copies of the version, but this means an implicit assumption that metadata store will always return the version+1, right?

Yes, I think so. In my current implementation, this is the case because of my shameless reusing of the Version struct but it is not strictly required right now. I could add this as a requirement for all MetadataStore implementations.

crates/metadata-store/src/lib.rs Outdated Show resolved Hide resolved
/// Metadata store abstraction. The metadata store implementations need to support linearizable
/// reads and atomic compare and swap operations.
#[async_trait]
pub trait MetadataStore: Send + Sync {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, does the trait itself need to be Send+Sync?

crates/metadata-store/src/lib.rs Outdated Show resolved Hide resolved
@tillrohrmann
Copy link
Contributor Author

I've added a commit outlining how the trait with explicit version propagation could look like.

Copy link
Contributor

@AhmedSoliman AhmedSoliman left a comment

Choose a reason for hiding this comment

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

🍾 good to go after making linter happy and fixing the mismatching comment.

crates/metadata-store/src/lib.rs Outdated Show resolved Hide resolved
@tillrohrmann tillrohrmann force-pushed the issues/1281 branch 2 times, most recently from c80f41b to d256a00 Compare March 19, 2024 15:27
@tillrohrmann tillrohrmann marked this pull request as ready for review March 19, 2024 15:50
@tillrohrmann
Copy link
Contributor Author

Thanks for the swift review @AhmedSoliman :-) Merging this PR now.

Add MetadataStore variant with explicit version propagation
@tillrohrmann tillrohrmann merged commit 2d69c68 into restatedev:main Mar 20, 2024
4 checks passed
@tillrohrmann tillrohrmann deleted the issues/1281 branch March 20, 2024 16:06
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