From 413ab0eaedb12b8808897098263cefa4bc7a7663 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 10 Feb 2022 16:10:21 +0100 Subject: Small change to partition assignation algorithm This change helps ensure that nodes for each partition are spread over all datacenters, a property that wasn't ensured previously when going from a 2 DC deployment to a 3 DC deployment --- src/garage/cli/layout.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/garage') diff --git a/src/garage/cli/layout.rs b/src/garage/cli/layout.rs index 0d9e4fa4..e0aba1d1 100644 --- a/src/garage/cli/layout.rs +++ b/src/garage/cli/layout.rs @@ -196,6 +196,15 @@ pub async fn cmd_apply_layout( ) -> Result<(), Error> { let mut layout = fetch_layout(rpc_cli, rpc_host).await?; + layout.roles.merge(&layout.staging); + + if !layout.calculate_partition_assignation() { + return Err(Error::Message("Could not calculate new assignation of partitions to nodes. This can happen if there are less nodes than the desired number of copies of your data (see the replication_mode configuration parameter).".into())); + } + + layout.staging.clear(); + layout.staging_hash = blake2sum(&rmp_to_vec_all_named(&layout.staging).unwrap()[..]); + match apply_opt.version { None => { println!("Please pass the --version flag to ensure that you are writing the correct version of the cluster layout."); @@ -209,15 +218,6 @@ pub async fn cmd_apply_layout( } } - layout.roles.merge(&layout.staging); - - if !layout.calculate_partition_assignation() { - return Err(Error::Message("Could not calculate new assignation of partitions to nodes. This can happen if there are less nodes than the desired number of copies of your data (see the replication_mode configuration parameter).".into())); - } - - layout.staging.clear(); - layout.staging_hash = blake2sum(&rmp_to_vec_all_named(&layout.staging).unwrap()[..]); - layout.version += 1; send_layout(rpc_cli, rpc_host, layout).await?; -- cgit v1.2.3