From 5769f1524a6eaa2165a7e84795f80f0f621888e5 Mon Sep 17 00:00:00 2001 From: Alex Chi Z Date: Wed, 9 Jul 2025 11:15:36 -0400 Subject: [PATCH] fix(compute_ctl): set stripe size before connstring during respec Signed-off-by: Alex Chi Z --- compute_tools/src/config.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compute_tools/src/config.rs b/compute_tools/src/config.rs index 169de5c963..8c35ad7c94 100644 --- a/compute_tools/src/config.rs +++ b/compute_tools/src/config.rs @@ -56,12 +56,15 @@ pub fn write_postgres_conf( // Add options for connecting to storage writeln!(file, "# Neon storage settings")?; - if let Some(s) = &spec.pageserver_connstring { - writeln!(file, "neon.pageserver_connstring={}", escape_conf_value(s))?; - } + // Setting stripe size before connstring is required to avoid compute routing keys to the wrong shard. + // Otherwise, if we set the connstring first and then stripe size, there will be a very small window + // where the default stripe size is used and the connstring is set. if let Some(stripe_size) = spec.shard_stripe_size { writeln!(file, "neon.stripe_size={stripe_size}")?; } + if let Some(s) = &spec.pageserver_connstring { + writeln!(file, "neon.pageserver_connstring={}", escape_conf_value(s))?; + } if !spec.safekeeper_connstrings.is_empty() { let mut neon_safekeepers_value = String::new(); tracing::info!(