-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Description
If I add check for active_wait_requests
in this test:
src/conn/pool/mod.rs
#[tokio::test]
async fn should_remove_waker_of_cancelled_task() {
let pool = pool_with_one_connection();
let only_conn = pool.get_conn().await.unwrap();
let join_handle = tokio::spawn(timeout(Duration::from_secs(1), pool.get_conn()));
sleep(Duration::from_secs(2)).await;
match join_handle.await.unwrap() {
Err(_elapsed) => (),
_ => panic!("unexpected Ok()"),
}
drop(only_conn);
assert_eq!(0, pool.inner.exchange.lock().unwrap().waiting.queue.len());
assert_eq!(0, pool.metrics().active_wait_requests.load(Ordering::Relaxed)); // <---- NEW CHECK
}
then i get error
thread 'conn::pool::test::should_remove_waker_of_cancelled_task' panicked at src/conn/pool/mod.rs:1015:9:
assertion `left == right` failed
left: 0
right: 1
I even try to add sleep
sleep(Duration::from_secs(10)).await;
assert_eq!(0, pool.metrics().active_wait_requests.load(Ordering::Relaxed));
same error.
How I understand, for this "canceled" task, function poll_new_conn
called twice and .active_wait_requests.fetch_add(1, atomic::Ordering::Relaxed);
called twice too.
First here: conn/pool/mod.rs:425
. Second here: conn/pool/mod.rs:343
P.S. it will be great, if PoolOpts
has function with_acquire_timeout(timeout: Option<Duration>)
and "cancel" pool.get_conn()
if provided.
Metadata
Metadata
Assignees
Labels
No labels