Compare commits

...

3 Commits

Author SHA1 Message Date
Mostafa
ef811c4223 fix 2025-01-23 21:25:03 -06:00
Mostafa
527ecebaec fix tests 2025-01-23 21:09:38 -06:00
Mostafa
03c291f171 Avoid holding on to pools after reload 2025-01-23 20:32:48 -06:00

View File

@@ -858,6 +858,14 @@ where
// The query router determines where the query is going to go,
// e.g. primary, replica, which shard.
let mut query_router = QueryRouter::new();
let pool_settings = if self.admin {
// Admin clients do not use pools.
ConnectionPool::default().settings
} else {
self.get_pool().await?.settings
};
query_router.update_pool_settings(&pool_settings);
query_router.set_default_role();
self.stats.register(self.stats.clone());
@@ -870,19 +878,6 @@ where
&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.
// We expect the client to either start a transaction with regular queries
// or issue commands for our sharding and server selection protocol.
@@ -933,6 +928,18 @@ where
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);
// Handle all custom protocol commands, if any.
if self
.handle_custom_protocol(&mut query_router, &message, &pool)
@@ -1055,11 +1062,12 @@ where
};
// Check if the pool is paused and wait until it's resumed.
pool.wait_paused().await;
// Refresh pool information, something might have changed.
pool = self.get_pool().await?;
query_router.update_pool_settings(&pool.settings);
if pool.paused() {
pool.wait_paused().await;
// Refresh pool information, something might have changed.
pool = self.get_pool().await?;
query_router.update_pool_settings(&pool.settings);
}
debug!("Waiting for connection from pool");
if !self.admin {