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:
Zain Kabani
2023-10-20 02:49:05 -04:00
committed by GitHub
parent 2c7bf52c17
commit d37df43a90
4 changed files with 32 additions and 26 deletions

View File

@@ -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();