Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Adds option to log which parameter status is changed by the client #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 8 src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ pub struct Pool {
#[serde(default = "Pool::default_cleanup_server_connections")]
pub cleanup_server_connections: bool,

#[serde(default)] // False
pub log_client_parameter_status_changes: bool,

pub plugins: Option<Plugins>,
pub shards: BTreeMap<String, Shard>,
pub users: BTreeMap<String, User>,
Expand Down Expand Up @@ -696,6 +699,7 @@ impl Default for Pool {
server_lifetime: None,
plugins: None,
cleanup_server_connections: true,
log_client_parameter_status_changes: false,
}
}
}
Expand Down Expand Up @@ -1157,6 +1161,10 @@ impl Config {
"[pool: {}] 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!(
"[pool: {}] Plugins: {}",
pool_name,
Expand Down
1 change: 1 addition & 0 deletions 1 src/mirrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl MirroredClient {
Arc::new(RwLock::new(None)),
None,
true,
false,
);

Pool::builder()
Expand Down
7 changes: 7 additions & 0 deletions 7 src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ impl ConnectionPool {
None => config.plugins.clone(),
},
pool_config.cleanup_server_connections,
pool_config.log_client_parameter_status_changes,
);

let connect_timeout = match pool_config.connect_timeout {
Expand Down Expand Up @@ -956,6 +957,9 @@ pub struct ServerPool {

/// Should we clean up dirty connections before putting them into the pool?
cleanup_connections: bool,

/// Log client parameter status changes
log_client_parameter_status_changes: bool,
}

impl ServerPool {
Expand All @@ -967,6 +971,7 @@ impl ServerPool {
auth_hash: Arc<RwLock<Option<String>>>,
plugins: Option<Plugins>,
cleanup_connections: bool,
log_client_parameter_status_changes: bool,
) -> ServerPool {
ServerPool {
address,
Expand All @@ -976,6 +981,7 @@ impl ServerPool {
auth_hash,
plugins,
cleanup_connections,
log_client_parameter_status_changes,
}
}
}
Expand Down Expand Up @@ -1005,6 +1011,7 @@ impl ManageConnection for ServerPool {
stats.clone(),
self.auth_hash.clone(),
self.cleanup_connections,
self.log_client_parameter_status_changes,
)
.await
{
Expand Down
9 changes: 9 additions & 0 deletions 9 src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ pub struct Server {
/// Should clean up dirty connections?
cleanup_connections: bool,

/// Log client parameter status changes
log_client_parameter_status_changes: bool,

/// Prepared statements
prepared_statements: BTreeSet<String>,
}
Expand All @@ -337,6 +340,7 @@ impl Server {
stats: Arc<ServerStats>,
auth_hash: Arc<RwLock<Option<String>>>,
cleanup_connections: bool,
log_client_parameter_status_changes: bool,
) -> Result<Server, Error> {
let cached_resolver = CACHED_RESOLVER.load();
let mut addr_set: Option<AddrSet> = None;
Expand Down Expand Up @@ -825,6 +829,7 @@ impl Server {
)),
},
cleanup_connections,
log_client_parameter_status_changes,
prepared_statements: BTreeSet::new(),
};

Expand Down Expand Up @@ -1009,6 +1014,9 @@ impl Server {

if let Some(client_server_parameters) = client_server_parameters.as_mut() {
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);
Expand Down Expand Up @@ -1373,6 +1381,7 @@ impl Server {
Arc::new(ServerStats::default()),
Arc::new(RwLock::new(None)),
true,
false,
)
.await?;
debug!("Connected!, sending query.");
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.