mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-03 11:32:56 +00:00
introduce separate reload commands
This commit is contained in:
@@ -2134,6 +2134,25 @@ impl ComputeNode {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Tell postgres/pgbouncer/local_proxy to reload their configurations.
|
||||
#[instrument(skip_all)]
|
||||
pub fn reload(&self, spec: ComputeSpec) -> Result<()> {
|
||||
let rt = tokio::runtime::Handle::current();
|
||||
if spec.pgbouncer_settings.is_some() {
|
||||
rt.block_on(reload_pgbouncer())?;
|
||||
}
|
||||
if spec.local_proxy_config.is_some() {
|
||||
local_proxy::reload()?;
|
||||
}
|
||||
self.pg_reload_conf()?;
|
||||
|
||||
let unknown_op = "unknown".to_string();
|
||||
let op_id = spec.operation_uuid.as_ref().unwrap_or(&unknown_op);
|
||||
info!("finished reload of compute node for operation {op_id}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub fn configure_as_primary(&self, compute_state: &ComputeState) -> Result<()> {
|
||||
let pspec = compute_state.pspec.as_ref().expect("spec must be set");
|
||||
|
||||
@@ -11,9 +11,11 @@ use utils::pid_file::{self, PidFileRead};
|
||||
|
||||
pub fn configure(local_proxy: &LocalProxySpec) -> Result<()> {
|
||||
write_local_proxy_conf("/etc/local_proxy/config.json".as_ref(), local_proxy)?;
|
||||
notify_local_proxy("/etc/local_proxy/pid".as_ref())?;
|
||||
reload()
|
||||
}
|
||||
|
||||
Ok(())
|
||||
pub fn reload() -> Result<()> {
|
||||
notify_local_proxy("/etc/local_proxy/pid".as_ref())
|
||||
}
|
||||
|
||||
/// Create or completely rewrite configuration file specified by `path`
|
||||
|
||||
@@ -466,13 +466,7 @@ fn update_pgbouncer_ini(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Tune pgbouncer.
|
||||
/// 1. Apply new config using pgbouncer admin console
|
||||
/// 2. Add new values to pgbouncer.ini to preserve them after restart
|
||||
pub async fn tune_pgbouncer(
|
||||
mut pgbouncer_config: IndexMap<String, String>,
|
||||
tls_config: Option<TlsConfig>,
|
||||
) -> Result<()> {
|
||||
async fn connect() -> Result<tokio_postgres::Client> {
|
||||
let pgbouncer_connstr = if std::env::var_os("AUTOSCALING").is_some() {
|
||||
// for VMs use pgbouncer specific way to connect to
|
||||
// pgbouncer admin console without password
|
||||
@@ -518,6 +512,16 @@ pub async fn tune_pgbouncer(
|
||||
}
|
||||
};
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
/// Tune pgbouncer.
|
||||
/// 1. Apply new config to pgbouncer.ini
|
||||
/// 2. Notify pgbouncer to reload
|
||||
pub async fn tune_pgbouncer(
|
||||
mut pgbouncer_config: IndexMap<String, String>,
|
||||
tls_config: Option<TlsConfig>,
|
||||
) -> Result<()> {
|
||||
if let Some(tls_config) = tls_config {
|
||||
// pgbouncer starts in a half-ok state if it cannot find these files.
|
||||
// It will default to client_tls_sslmode=deny, which causes proxy to error.
|
||||
@@ -550,9 +554,16 @@ pub async fn tune_pgbouncer(
|
||||
|
||||
info!("Applying pgbouncer setting change");
|
||||
|
||||
reload_pgbouncer().await
|
||||
}
|
||||
|
||||
/// Reload pgbouncer.
|
||||
pub async fn reload_pgbouncer() -> Result<()> {
|
||||
let client = connect().await?;
|
||||
|
||||
if let Err(err) = client.simple_query("RELOAD").await {
|
||||
// Don't fail on error, just print it into log
|
||||
error!("Failed to apply pgbouncer setting change, {err}",);
|
||||
error!("Failed to apply pgbouncer setting change: {err}",);
|
||||
};
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user