mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-27 10:46:30 +00:00
Avoid holding on to pools after reload
This commit is contained in:
@@ -870,19 +870,6 @@ where
|
|||||||
&self.pool_name,
|
&self.pool_name,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get a pool instance referenced by the most up-to-date
|
|
||||||
// pointer. This ensures we always read the latest config
|
|
||||||
// when starting a query.
|
|
||||||
let mut pool = if self.admin {
|
|
||||||
// Admin clients do not use pools.
|
|
||||||
ConnectionPool::default()
|
|
||||||
} else {
|
|
||||||
self.get_pool().await?
|
|
||||||
};
|
|
||||||
|
|
||||||
query_router.update_pool_settings(&pool.settings);
|
|
||||||
query_router.set_default_role();
|
|
||||||
|
|
||||||
// Our custom protocol loop.
|
// Our custom protocol loop.
|
||||||
// We expect the client to either start a transaction with regular queries
|
// We expect the client to either start a transaction with regular queries
|
||||||
// or issue commands for our sharding and server selection protocol.
|
// or issue commands for our sharding and server selection protocol.
|
||||||
@@ -933,6 +920,19 @@ where
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a pool instance referenced by the most up-to-date
|
||||||
|
// pointer. This ensures we always read the latest config
|
||||||
|
// when starting a query.
|
||||||
|
let mut pool = if self.admin {
|
||||||
|
// Admin clients do not use pools.
|
||||||
|
ConnectionPool::default()
|
||||||
|
} else {
|
||||||
|
self.get_pool().await?
|
||||||
|
};
|
||||||
|
|
||||||
|
query_router.update_pool_settings(&pool.settings);
|
||||||
|
query_router.set_default_role();
|
||||||
|
|
||||||
// Handle all custom protocol commands, if any.
|
// Handle all custom protocol commands, if any.
|
||||||
if self
|
if self
|
||||||
.handle_custom_protocol(&mut query_router, &message, &pool)
|
.handle_custom_protocol(&mut query_router, &message, &pool)
|
||||||
@@ -1055,11 +1055,12 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Check if the pool is paused and wait until it's resumed.
|
// Check if the pool is paused and wait until it's resumed.
|
||||||
pool.wait_paused().await;
|
if pool.paused() {
|
||||||
|
pool.wait_paused().await;
|
||||||
// Refresh pool information, something might have changed.
|
// Refresh pool information, something might have changed.
|
||||||
pool = self.get_pool().await?;
|
pool = self.get_pool().await?;
|
||||||
query_router.update_pool_settings(&pool.settings);
|
query_router.update_pool_settings(&pool.settings);
|
||||||
|
}
|
||||||
|
|
||||||
debug!("Waiting for connection from pool");
|
debug!("Waiting for connection from pool");
|
||||||
if !self.admin {
|
if !self.admin {
|
||||||
|
|||||||
Reference in New Issue
Block a user