Explicitly set port in postgresql.conf

Hadron doesn't bind Postgres to the default Postgres port of 5432 it
seems, and requires using a different port. Neon binds to the default
port. Writing out the default port makes no difference, so do it always
regardless of Lakebase mode.

Signed-off-by: Tristan Partin <tristan.partin@databricks.com>
This commit is contained in:
Tristan Partin
2025-07-24 21:48:12 -05:00
parent cf3f5f23b3
commit 7ea879d47e
2 changed files with 17 additions and 0 deletions

View File

@@ -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(),

View File

@@ -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<TlsConfig>,
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() {