Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store: Avoid panic if GRAPH_STORE_CONNECTION_MIN_IDLE exceeds pool_size #3489

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion store/postgres/src/connection_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use graph::cheap_clone::CheapClone;
use graph::constraint_violation;
use graph::prelude::tokio;
use graph::prelude::tokio::time::Instant;
use graph::slog::warn;
use graph::util::timed_rw_lock::TimedMutex;
use graph::{
prelude::{
Expand Down Expand Up @@ -727,12 +728,25 @@ impl PoolInner {

// Connect to Postgres
let conn_manager = ConnectionManager::new(postgres_url.clone());
let min_idle = ENV_VARS.store.connection_min_idle.filter(|min_idle| {
if *min_idle <= pool_size {
true
} else {
warn!(
logger_pool,
"Configuration error: min idle {} exceeds pool size {}, ignoring min idle",
min_idle,
pool_size
);
false
}
});
let builder: Builder<ConnectionManager<PgConnection>> = Pool::builder()
.error_handler(error_handler.clone())
.event_handler(event_handler.clone())
.connection_timeout(ENV_VARS.store.connection_timeout)
.max_size(pool_size)
.min_idle(ENV_VARS.store.connection_min_idle)
.min_idle(min_idle)
.idle_timeout(Some(ENV_VARS.store.connection_idle_timeout));
let pool = builder.build_unchecked(conn_manager);
let fdw_pool = fdw_pool_size.map(|pool_size| {
Expand Down