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

Switch consensus to a runtime configuration #565

Merged
merged 3 commits into from
May 6, 2022

Conversation

agourlay
Copy link
Member

@agourlay agourlay commented May 5, 2022

This PR switch the consensus from a conditional compilation cargo feature to a runtime configuration #511

This means:

  • the consensus code is now compiled by default
  • the consensus unit tests are executed by default
  • the distributed deployment toggle is the cluster.enabled configuration field (false by default)
  • the integration test bash script has a new parameter to toggle the distributed mode
  • the toc is aware of the distribution mode

@agourlay agourlay force-pushed the runtime-configuration-consensus branch from 0b20e9d to 5b07a9a Compare May 5, 2022 18:52
@agourlay agourlay force-pushed the runtime-configuration-consensus branch from 5b07a9a to 1fb720c Compare May 5, 2022 19:22
@agourlay agourlay linked an issue May 5, 2022 that may be closed by this pull request
@@ -51,7 +51,7 @@ jobs:
run: .github/scripts/protoc.sh
shell: bash
- name: Build
run: cargo build --features consensus
Copy link
Member Author

Choose a reason for hiding this comment

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

Given that the binaries are now equivalent, we could also just move ./tests/integration-tests.sh distributed as an additional step to the previous job to not compile twice.

src/main.rs Outdated
runtime_handle.block_on(async {
for collection in toc.all_collections().await {
log::info!("Loaded collection: {}", collection);
}
});

#[cfg(feature = "consensus")]
let (propose_sender, propose_receiver) = std::sync::mpsc::channel();
Copy link
Member Author

Choose a reason for hiding this comment

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

the channel and the propose_sender are always initialized regardless of the configuration,

@agourlay agourlay changed the title switch consensus to a runtime configuration Switch consensus to a runtime configuration May 5, 2022
@agourlay agourlay marked this pull request as ready for review May 5, 2022 19:30
@agourlay agourlay requested review from e-ivkov and generall May 5, 2022 19:30
@@ -355,21 +337,17 @@ impl TableOfContent {
operation: CollectionMetaOperations,
wait_timeout: Option<Duration>,
) -> Result<bool, StorageError> {
#[cfg(feature = "consensus")]
{
if self.distributed_mode {
Copy link
Member Author

@agourlay agourlay May 5, 2022

Choose a reason for hiding this comment

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

this is where the rubber meets the road

@@ -30,25 +30,6 @@ jobs:
- name: Run tests
run: cargo test --all

test-consensus:
Copy link
Member Author

Choose a reason for hiding this comment

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

removed because the consensus unit tests are now executed by default

@@ -129,7 +116,7 @@ impl TableOfContent {
Wal::open(collections_meta_wal_path).unwrap(),
))
};
#[cfg(feature = "consensus")]

Copy link
Member Author

Choose a reason for hiding this comment

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

the raft state is now always initialized, not sure if it could be problematic TBH

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a small file, shouldn't really matter to user I think

Copy link
Member

@generall generall left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@e-ivkov e-ivkov left a comment

Choose a reason for hiding this comment

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

Looks nice

@agourlay agourlay merged commit c739652 into master May 6, 2022
@agourlay agourlay deleted the runtime-configuration-consensus branch May 6, 2022 15:56
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.

[sharding] Enable consensus via runtime configuration
3 participants