sql: use semaphore to limit access to the connection pool

This ensures that if multiple connections are returned
to the pool at the same time, waiters get them in the order
they were placed in the queue.
This commit is contained in:
link2xt
2023-02-19 17:04:18 +00:00
parent 609fc67f0d
commit 10066b2bc7
3 changed files with 23 additions and 19 deletions

View File

@@ -338,7 +338,7 @@ impl Sql {
pub(crate) async fn get_conn(&self) -> Result<PooledConnection> {
let lock = self.pool.read().await;
let pool = lock.as_ref().context("no SQL connection")?;
let conn = pool.get().await;
let conn = pool.get().await?;
Ok(conn)
}