mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-23 06:30:05 +00:00
fix: use verified recycling method for PostgreSQL connection pool (#7407)
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
@@ -291,7 +291,7 @@ pub async fn metasrv_builder(
|
|||||||
|
|
||||||
use common_meta::distributed_time_constants::POSTGRES_KEEP_ALIVE_SECS;
|
use common_meta::distributed_time_constants::POSTGRES_KEEP_ALIVE_SECS;
|
||||||
use common_meta::kv_backend::rds::PgStore;
|
use common_meta::kv_backend::rds::PgStore;
|
||||||
use deadpool_postgres::Config;
|
use deadpool_postgres::{Config, ManagerConfig, RecyclingMethod};
|
||||||
|
|
||||||
use crate::election::rds::postgres::{ElectionPgClient, PgElection};
|
use crate::election::rds::postgres::{ElectionPgClient, PgElection};
|
||||||
use crate::utils::postgres::create_postgres_pool;
|
use crate::utils::postgres::create_postgres_pool;
|
||||||
@@ -305,9 +305,16 @@ pub async fn metasrv_builder(
|
|||||||
let mut cfg = Config::new();
|
let mut cfg = Config::new();
|
||||||
cfg.keepalives = Some(true);
|
cfg.keepalives = Some(true);
|
||||||
cfg.keepalives_idle = Some(Duration::from_secs(POSTGRES_KEEP_ALIVE_SECS));
|
cfg.keepalives_idle = Some(Duration::from_secs(POSTGRES_KEEP_ALIVE_SECS));
|
||||||
// We use a separate pool for election since we need a different session keep-alive idle time.
|
cfg.manager = Some(ManagerConfig {
|
||||||
let pool = create_postgres_pool(&opts.store_addrs, Some(cfg), opts.backend_tls.clone())
|
recycling_method: RecyclingMethod::Verified,
|
||||||
.await?;
|
});
|
||||||
|
// Use a dedicated pool for the election client to allow customized session settings.
|
||||||
|
let pool = create_postgres_pool(
|
||||||
|
&opts.store_addrs,
|
||||||
|
Some(cfg.clone()),
|
||||||
|
opts.backend_tls.clone(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let election_client = ElectionPgClient::new(
|
let election_client = ElectionPgClient::new(
|
||||||
pool,
|
pool,
|
||||||
@@ -327,8 +334,8 @@ pub async fn metasrv_builder(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let pool =
|
let pool = create_postgres_pool(&opts.store_addrs, Some(cfg), opts.backend_tls.clone())
|
||||||
create_postgres_pool(&opts.store_addrs, None, opts.backend_tls.clone()).await?;
|
.await?;
|
||||||
let kv_backend = PgStore::with_pg_pool(
|
let kv_backend = PgStore::with_pg_pool(
|
||||||
pool,
|
pool,
|
||||||
opts.meta_schema_name.as_deref(),
|
opts.meta_schema_name.as_deref(),
|
||||||
|
|||||||
Reference in New Issue
Block a user