mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Adds option to log which parameter status is changed by the client (#550)
This commit is contained in:
@@ -547,6 +547,9 @@ pub struct Pool {
|
|||||||
#[serde(default = "Pool::default_cleanup_server_connections")]
|
#[serde(default = "Pool::default_cleanup_server_connections")]
|
||||||
pub cleanup_server_connections: bool,
|
pub cleanup_server_connections: bool,
|
||||||
|
|
||||||
|
#[serde(default)] // False
|
||||||
|
pub log_client_parameter_status_changes: bool,
|
||||||
|
|
||||||
pub plugins: Option<Plugins>,
|
pub plugins: Option<Plugins>,
|
||||||
pub shards: BTreeMap<String, Shard>,
|
pub shards: BTreeMap<String, Shard>,
|
||||||
pub users: BTreeMap<String, User>,
|
pub users: BTreeMap<String, User>,
|
||||||
@@ -696,6 +699,7 @@ impl Default for Pool {
|
|||||||
server_lifetime: None,
|
server_lifetime: None,
|
||||||
plugins: None,
|
plugins: None,
|
||||||
cleanup_server_connections: true,
|
cleanup_server_connections: true,
|
||||||
|
log_client_parameter_status_changes: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1157,6 +1161,10 @@ impl Config {
|
|||||||
"[pool: {}] Cleanup server connections: {}",
|
"[pool: {}] Cleanup server connections: {}",
|
||||||
pool_name, pool_config.cleanup_server_connections
|
pool_name, pool_config.cleanup_server_connections
|
||||||
);
|
);
|
||||||
|
info!(
|
||||||
|
"[pool: {}] Log client parameter status changes: {}",
|
||||||
|
pool_name, pool_config.log_client_parameter_status_changes
|
||||||
|
);
|
||||||
info!(
|
info!(
|
||||||
"[pool: {}] Plugins: {}",
|
"[pool: {}] Plugins: {}",
|
||||||
pool_name,
|
pool_name,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ impl MirroredClient {
|
|||||||
Arc::new(RwLock::new(None)),
|
Arc::new(RwLock::new(None)),
|
||||||
None,
|
None,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
Pool::builder()
|
Pool::builder()
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ impl ConnectionPool {
|
|||||||
None => config.plugins.clone(),
|
None => config.plugins.clone(),
|
||||||
},
|
},
|
||||||
pool_config.cleanup_server_connections,
|
pool_config.cleanup_server_connections,
|
||||||
|
pool_config.log_client_parameter_status_changes,
|
||||||
);
|
);
|
||||||
|
|
||||||
let connect_timeout = match pool_config.connect_timeout {
|
let connect_timeout = match pool_config.connect_timeout {
|
||||||
@@ -956,6 +957,9 @@ pub struct ServerPool {
|
|||||||
|
|
||||||
/// Should we clean up dirty connections before putting them into the pool?
|
/// Should we clean up dirty connections before putting them into the pool?
|
||||||
cleanup_connections: bool,
|
cleanup_connections: bool,
|
||||||
|
|
||||||
|
/// Log client parameter status changes
|
||||||
|
log_client_parameter_status_changes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerPool {
|
impl ServerPool {
|
||||||
@@ -967,6 +971,7 @@ impl ServerPool {
|
|||||||
auth_hash: Arc<RwLock<Option<String>>>,
|
auth_hash: Arc<RwLock<Option<String>>>,
|
||||||
plugins: Option<Plugins>,
|
plugins: Option<Plugins>,
|
||||||
cleanup_connections: bool,
|
cleanup_connections: bool,
|
||||||
|
log_client_parameter_status_changes: bool,
|
||||||
) -> ServerPool {
|
) -> ServerPool {
|
||||||
ServerPool {
|
ServerPool {
|
||||||
address,
|
address,
|
||||||
@@ -976,6 +981,7 @@ impl ServerPool {
|
|||||||
auth_hash,
|
auth_hash,
|
||||||
plugins,
|
plugins,
|
||||||
cleanup_connections,
|
cleanup_connections,
|
||||||
|
log_client_parameter_status_changes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1005,6 +1011,7 @@ impl ManageConnection for ServerPool {
|
|||||||
stats.clone(),
|
stats.clone(),
|
||||||
self.auth_hash.clone(),
|
self.auth_hash.clone(),
|
||||||
self.cleanup_connections,
|
self.cleanup_connections,
|
||||||
|
self.log_client_parameter_status_changes,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -322,6 +322,9 @@ pub struct Server {
|
|||||||
/// Should clean up dirty connections?
|
/// Should clean up dirty connections?
|
||||||
cleanup_connections: bool,
|
cleanup_connections: bool,
|
||||||
|
|
||||||
|
/// Log client parameter status changes
|
||||||
|
log_client_parameter_status_changes: bool,
|
||||||
|
|
||||||
/// Prepared statements
|
/// Prepared statements
|
||||||
prepared_statements: BTreeSet<String>,
|
prepared_statements: BTreeSet<String>,
|
||||||
}
|
}
|
||||||
@@ -337,6 +340,7 @@ impl Server {
|
|||||||
stats: Arc<ServerStats>,
|
stats: Arc<ServerStats>,
|
||||||
auth_hash: Arc<RwLock<Option<String>>>,
|
auth_hash: Arc<RwLock<Option<String>>>,
|
||||||
cleanup_connections: bool,
|
cleanup_connections: bool,
|
||||||
|
log_client_parameter_status_changes: bool,
|
||||||
) -> Result<Server, Error> {
|
) -> Result<Server, Error> {
|
||||||
let cached_resolver = CACHED_RESOLVER.load();
|
let cached_resolver = CACHED_RESOLVER.load();
|
||||||
let mut addr_set: Option<AddrSet> = None;
|
let mut addr_set: Option<AddrSet> = None;
|
||||||
@@ -825,6 +829,7 @@ impl Server {
|
|||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
cleanup_connections,
|
cleanup_connections,
|
||||||
|
log_client_parameter_status_changes,
|
||||||
prepared_statements: BTreeSet::new(),
|
prepared_statements: BTreeSet::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1009,6 +1014,9 @@ impl Server {
|
|||||||
|
|
||||||
if let Some(client_server_parameters) = client_server_parameters.as_mut() {
|
if let Some(client_server_parameters) = client_server_parameters.as_mut() {
|
||||||
client_server_parameters.set_param(key.clone(), value.clone(), false);
|
client_server_parameters.set_param(key.clone(), value.clone(), false);
|
||||||
|
if self.log_client_parameter_status_changes {
|
||||||
|
info!("Client parameter status change: {} = {}", key, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.server_parameters.set_param(key, value, false);
|
self.server_parameters.set_param(key, value, false);
|
||||||
@@ -1382,6 +1390,7 @@ impl Server {
|
|||||||
Arc::new(ServerStats::default()),
|
Arc::new(ServerStats::default()),
|
||||||
Arc::new(RwLock::new(None)),
|
Arc::new(RwLock::new(None)),
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
debug!("Connected!, sending query.");
|
debug!("Connected!, sending query.");
|
||||||
|
|||||||
Reference in New Issue
Block a user