mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Compare commits
3 Commits
mostafa_te
...
mostafa_av
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef811c4223 | ||
|
|
527ecebaec | ||
|
|
03c291f171 |
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user