diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index b88a99741c..b4ea43b300 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -1459,12 +1459,18 @@ impl ComputeNode { let tls_config = self.tls_config(&pspec.spec); let databricks_settings = spec.databricks_settings.as_ref(); + let postgres_port = self + .params + .connstr + .port() + .expect("port must be present in connstr"); // Remove/create an empty pgdata directory and put configuration there. self.create_pgdata()?; config::write_postgres_conf( pgdata_path, &self.params, &pspec.spec, + postgres_port, self.params.internal_http_port, tls_config, databricks_settings, @@ -1960,10 +1966,16 @@ impl ComputeNode { // Write new config let pgdata_path = Path::new(&self.params.pgdata); + let postgres_port = self + .params + .connstr + .port() + .expect("port must be present in connstr"); config::write_postgres_conf( pgdata_path, &self.params, &spec, + postgres_port, self.params.internal_http_port, tls_config, spec.databricks_settings.as_ref(), diff --git a/compute_tools/src/config.rs b/compute_tools/src/config.rs index f843a4c698..c13b302a59 100644 --- a/compute_tools/src/config.rs +++ b/compute_tools/src/config.rs @@ -47,6 +47,7 @@ pub fn write_postgres_conf( pgdata_path: &Path, params: &ComputeNodeParams, spec: &ComputeSpec, + postgres_port: u16, extension_server_port: u16, tls_config: &Option, databricks_settings: Option<&DatabricksSettings>, @@ -283,6 +284,10 @@ pub fn write_postgres_conf( writeln!(file, "neon.disable_logical_replication_subscribers=false")?; } + // Explicitly set the port based on the connstr, overriding any previous port setting. + // Note: It is important that we don't specify a different port again after this. + writeln!(file, "port = {postgres_port}")?; + // We need Postgres to send logs to rsyslog so that we can forward them // further to customers' log aggregation systems. if spec.logs_export_host.is_some() {