mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-28 03:06:29 +00:00
Reduces the amount of time the get_pool operation takes (#625)
* Reduces the amount of time the get_pool operation takes * trigger build * Fix admin
This commit is contained in:
@@ -542,7 +542,7 @@ where
|
||||
}
|
||||
// Authenticate normal user.
|
||||
else {
|
||||
let mut pool = match get_pool(pool_name, username) {
|
||||
let pool = match get_pool(pool_name, username) {
|
||||
Some(pool) => pool,
|
||||
None => {
|
||||
error_response(
|
||||
@@ -800,6 +800,18 @@ 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);
|
||||
|
||||
// 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.
|
||||
@@ -853,12 +865,6 @@ 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 = self.get_pool().await?;
|
||||
query_router.update_pool_settings(pool.settings.clone());
|
||||
|
||||
let mut initial_parsed_ast = None;
|
||||
|
||||
match message[0] as char {
|
||||
@@ -990,12 +996,11 @@ where
|
||||
};
|
||||
|
||||
// Check if the pool is paused and wait until it's resumed.
|
||||
if pool.wait_paused().await {
|
||||
// Refresh pool information, something might have changed.
|
||||
pool = self.get_pool().await?;
|
||||
}
|
||||
pool.wait_paused().await;
|
||||
|
||||
query_router.update_pool_settings(pool.settings.clone());
|
||||
// Refresh pool information, something might have changed.
|
||||
pool = self.get_pool().await?;
|
||||
query_router.update_pool_settings(&pool.settings);
|
||||
|
||||
let current_shard = query_router.shard();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user