diff --git a/control_plane/src/bin/neon_local.rs b/control_plane/src/bin/neon_local.rs index 184ce7be39..26ad910d18 100644 --- a/control_plane/src/bin/neon_local.rs +++ b/control_plane/src/bin/neon_local.rs @@ -451,7 +451,6 @@ async fn handle_tenant( // FIXME: passing None for ancestor_start_lsn is not kosher in a sharded world: we can't have // different shards picking different start lsns. Maybe we have to teach attachment service // to let shard 0 branch first and then propagate the chosen LSN to other shards. - attachment_service.tenant_timeline_create( tenant_id, TimelineCreateRequest { @@ -838,6 +837,14 @@ async fn handle_endpoint(ep_match: &ArgMatches, env: &local_env::LocalEnv) -> Re endpoint.timeline_id, )?; + let attachment_service = AttachmentService::from_env(env); + let pageservers = attachment_service + .tenant_locate(endpoint.tenant_id)? + .shards + .into_iter() + .map(|shard| (shard.listen_pg_addr, shard.listen_pg_port)) + .collect::>(); + let ps_conf = env.get_pageserver_conf(pageserver_id)?; let auth_token = if matches!(ps_conf.pg_auth_type, AuthType::NeonJWT) { let claims = Claims::new(Some(endpoint.tenant_id), Scope::Tenant); @@ -849,7 +856,7 @@ async fn handle_endpoint(ep_match: &ArgMatches, env: &local_env::LocalEnv) -> Re println!("Starting existing endpoint {endpoint_id}..."); endpoint - .start(&auth_token, safekeepers, remote_ext_config) + .start(&auth_token, safekeepers, pageservers, remote_ext_config) .await?; } "reconfigure" => { diff --git a/control_plane/src/endpoint.rs b/control_plane/src/endpoint.rs index 071f22dc2b..f9645be575 100644 --- a/control_plane/src/endpoint.rs +++ b/control_plane/src/endpoint.rs @@ -464,10 +464,19 @@ impl Endpoint { } } + fn build_pageserver_connstr(pageservers: &[(String, u16)]) -> String { + pageservers + .iter() + .map(|(host, port)| format!("postgresql://no_user@{host}:{port}")) + .collect::>() + .join(",") + } + pub async fn start( &self, auth_token: &Option, safekeepers: Vec, + pageservers: Vec<(String, u16)>, remote_ext_config: Option<&String>, ) -> Result<()> { if self.status() == "running" { @@ -482,13 +491,8 @@ impl Endpoint { std::fs::remove_dir_all(self.pgdata())?; } - let pageserver_connstring = { - let config = &self.pageserver.pg_connection_config; - let (host, port) = (config.host(), config.port()); + let pageserver_connstring = Self::build_pageserver_connstr(&pageservers); - // NOTE: avoid spaces in connection string, because it is less error prone if we forward it somewhere. - format!("postgresql://no_user@{host}:{port}") - }; let mut safekeeper_connstrings = Vec::new(); if self.mode == ComputeMode::Primary { for sk_id in safekeepers {