diff --git a/src/client/legacy/pool.rs b/src/client/legacy/pool.rs index 5752ac5..2d03109 100644 --- a/src/client/legacy/pool.rs +++ b/src/client/legacy/pool.rs @@ -433,6 +433,14 @@ impl PoolInner { } else { return; }; + + // While someone might want a shorter duration, and it will be respected + // at checkout time, there's no need to wake up and proactively evict + // faster than this. + const MIN_CHECK: Duration = Duration::from_millis(90); + + let dur = dur.max(MIN_CHECK); + let (tx, rx) = oneshot::channel(); self.idle_interval_ref = Some(tx); @@ -991,8 +999,15 @@ mod tests { // Let the timer tick passed the expiration... tokio::time::sleep(Duration::from_millis(30)).await; - // Yield so the Interval can reap... - tokio::task::yield_now().await; + + // But minimum interval is higher, so nothing should have been reaped + assert_eq!( + pool.locked().idle.get(&key).map(|entries| entries.len()), + Some(3) + ); + + // Now wait passed the minimum interval more + tokio::time::sleep(Duration::from_millis(70)).await; assert!(!pool.locked().idle.contains_key(&key)); }