From eb1d6eb1fe59ffec495a061e82b66ca31a16115d Mon Sep 17 00:00:00 2001 From: HaoyuHuang Date: Fri, 25 Jul 2025 16:18:29 +0000 Subject: [PATCH] c --- compute_tools/src/compute.rs | 14 ++++---------- compute_tools/src/config.rs | 33 +++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index b4ea43b300..0490b038d5 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -1459,11 +1459,7 @@ 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"); + let postgres_port = self.params.connstr.port(); // Remove/create an empty pgdata directory and put configuration there. self.create_pgdata()?; config::write_postgres_conf( @@ -1474,6 +1470,7 @@ impl ComputeNode { self.params.internal_http_port, tls_config, databricks_settings, + self.params.lakebase_mode, )?; // Syncing safekeepers is only safe with primary nodes: if a primary @@ -1966,11 +1963,7 @@ 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"); + let postgres_port = self.params.connstr.port(); config::write_postgres_conf( pgdata_path, &self.params, @@ -1979,6 +1972,7 @@ impl ComputeNode { self.params.internal_http_port, tls_config, spec.databricks_settings.as_ref(), + self.params.lakebase_mode, )?; self.pg_reload_conf()?; diff --git a/compute_tools/src/config.rs b/compute_tools/src/config.rs index c13b302a59..55a1eda0b7 100644 --- a/compute_tools/src/config.rs +++ b/compute_tools/src/config.rs @@ -43,14 +43,16 @@ pub fn line_in_file(path: &Path, line: &str) -> Result { } /// Create or completely rewrite configuration file specified by `path` +#[allow(clippy::too_many_arguments)] pub fn write_postgres_conf( pgdata_path: &Path, params: &ComputeNodeParams, spec: &ComputeSpec, - postgres_port: u16, + postgres_port: Option, extension_server_port: u16, tls_config: &Option, databricks_settings: Option<&DatabricksSettings>, + lakebase_mode: bool, ) -> Result<()> { let path = pgdata_path.join("postgresql.conf"); // File::create() destroys the file content if it exists. @@ -284,26 +286,29 @@ 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() { writeln!(file, "log_destination='stderr,syslog'")?; } - // This is databricks specific settings. - // This should be at the end of the file but before `compute_ctl_temp_override.conf` below - // so that it can override any settings above. - // `compute_ctl_temp_override.conf` is intended to override any settings above during specific operations. - // To prevent potential breakage in the future, we keep it above `compute_ctl_temp_override.conf`. - writeln!(file, "# Databricks settings start")?; - if let Some(settings) = databricks_settings { - writeln!(file, "{}", settings.as_pg_settings())?; + if lakebase_mode { + // 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. + let port = postgres_port.expect("port must be present in connstr"); + writeln!(file, "port = {port}")?; + + // This is databricks specific settings. + // This should be at the end of the file but before `compute_ctl_temp_override.conf` below + // so that it can override any settings above. + // `compute_ctl_temp_override.conf` is intended to override any settings above during specific operations. + // To prevent potential breakage in the future, we keep it above `compute_ctl_temp_override.conf`. + writeln!(file, "# Databricks settings start")?; + if let Some(settings) = databricks_settings { + writeln!(file, "{}", settings.as_pg_settings())?; + } + writeln!(file, "# Databricks settings end")?; } - writeln!(file, "# Databricks settings end")?; // This is essential to keep this line at the end of the file, // because it is intended to override any settings above.