Skip to content

Commit

Permalink
pool: do not indefinitely leak timers (istio#993)
Browse files Browse the repository at this point in the history
We are storing these in a list and never removing. We don't use them, so
no need to store.

Co-authored-by: John Howard <[email protected]>
  • Loading branch information
istio-testing and howardjohn authored May 1, 2024
1 parent 708511b commit 8cdd228
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/proxy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use std::sync::atomic::{AtomicI32, AtomicU16, Ordering};
use std::sync::Arc;

use tokio::sync::watch;
use tokio::task;

use tokio::sync::Mutex;
use tracing::{debug, error, trace};
Expand Down Expand Up @@ -64,7 +63,6 @@ struct PoolState {
connected_pool: Arc<pingora_pool::ConnectionPool<ConnClient>>,
// this must be an atomic/concurrent-safe list-of-locks, so we can lock per-key, not globally, and avoid holding up all conn attempts
established_conn_writelock: flurry::HashMap<u64, Option<Arc<Mutex<()>>>>,
close_pollers: futures::stream::FuturesUnordered<task::JoinHandle<()>>,
pool_unused_release_timeout: Duration,
// This is merely a counter to track the overall number of conns this pool spawns
// to ensure we get unique poolkeys-per-new-conn, it is not a limit
Expand Down Expand Up @@ -165,7 +163,7 @@ impl PoolState {
let pool_ref = self.connected_pool.clone();
let pool_key_ref = pool_key.clone();
let release_timeout = self.pool_unused_release_timeout;
self.close_pollers.push(tokio::spawn(async move {
tokio::spawn(async move {
debug!(
"starting an idle timeout for connection {:#?}",
pool_key_ref
Expand All @@ -177,7 +175,7 @@ impl PoolState {
"connection {:#?} was removed/checked out/timed out of the pool",
pool_key_ref
)
}));
});
let _ = self.pool_notifier.send(true);
}

Expand Down Expand Up @@ -412,7 +410,6 @@ impl WorkloadHBONEPool {
// the pool is expected to track before the inner hashmap resizes.
connected_pool: Arc::new(pingora_pool::ConnectionPool::new(500)),
established_conn_writelock: flurry::HashMap::new(),
close_pollers: futures::stream::FuturesUnordered::new(),
pool_unused_release_timeout: pool_duration,
pool_global_conn_count: AtomicI32::new(0),
max_streamcount: max_count,
Expand Down

0 comments on commit 8cdd228

Please sign in to comment.