diff --git a/prover/proof_fri_compressor/src/main.rs b/prover/proof_fri_compressor/src/main.rs index 04f2935ead0d..90d937b6f309 100644 --- a/prover/proof_fri_compressor/src/main.rs +++ b/prover/proof_fri_compressor/src/main.rs @@ -48,13 +48,10 @@ async fn main() -> anyhow::Result<()> { let opt = Opt::from_args(); let config = FriProofCompressorConfig::from_env().context("FriProofCompressorConfig")?; let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?; - let pool = ConnectionPool::builder( - postgres_config.prover_url()?, - postgres_config.max_connections()?, - ) - .build() - .await - .context("failed to build a connection pool")?; + let pool = ConnectionPool::singleton(postgres_config.prover_url()?) + .build() + .await + .context("failed to build a connection pool")?; let object_store_config = ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?; let blob_store = ObjectStoreFactory::new(object_store_config.0) diff --git a/prover/prover_fri/src/main.rs b/prover/prover_fri/src/main.rs index ff59fdbabfcd..a1f1ae0088d1 100644 --- a/prover/prover_fri/src/main.rs +++ b/prover/prover_fri/src/main.rs @@ -119,13 +119,16 @@ async fn main() -> anyhow::Result<()> { circuit_ids_for_round_to_be_proven.clone() ); let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?; - let pool = ConnectionPool::builder( - postgres_config.prover_url()?, - postgres_config.max_connections()?, - ) - .build() - .await - .context("failed to build a connection pool")?; + + // There are 2 threads using the connection pool: + // 1. The prover thread, which is used to update the prover job status. + // 2. The socket listener thread, which is used to update the prover instance status. + const MAX_POOL_SIZE_FOR_PROVER: u32 = 2; + + let pool = ConnectionPool::builder(postgres_config.prover_url()?, MAX_POOL_SIZE_FOR_PROVER) + .build() + .await + .context("failed to build a connection pool")?; let port = prover_config.witness_vector_receiver_port; let prover_tasks = get_prover_tasks( prover_config, diff --git a/prover/witness_generator/src/main.rs b/prover/witness_generator/src/main.rs index c977f216104b..3b3b8d460339 100644 --- a/prover/witness_generator/src/main.rs +++ b/prover/witness_generator/src/main.rs @@ -96,13 +96,10 @@ async fn main() -> anyhow::Result<()> { .build() .await .context("failed to build a connection_pool")?; - let prover_connection_pool = ConnectionPool::builder( - postgres_config.prover_url()?, - postgres_config.max_connections()?, - ) - .build() - .await - .context("failed to build a prover_connection_pool")?; + let prover_connection_pool = ConnectionPool::singleton(postgres_config.prover_url()?) + .build() + .await + .context("failed to build a prover_connection_pool")?; let (stop_sender, stop_receiver) = watch::channel(false); let vk_commitments = get_cached_commitments(); let protocol_versions = prover_connection_pool diff --git a/prover/witness_vector_generator/src/main.rs b/prover/witness_vector_generator/src/main.rs index 1358680d3a11..79faa17c39cc 100644 --- a/prover/witness_vector_generator/src/main.rs +++ b/prover/witness_vector_generator/src/main.rs @@ -58,13 +58,10 @@ async fn main() -> anyhow::Result<()> { let exporter_config = PrometheusExporterConfig::pull(config.prometheus_listener_port); let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?; - let pool = ConnectionPool::builder( - postgres_config.prover_url()?, - postgres_config.max_connections()?, - ) - .build() - .await - .context("failed to build a connection pool")?; + let pool = ConnectionPool::singleton(postgres_config.prover_url()?) + .build() + .await + .context("failed to build a connection pool")?; let object_store_config = ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?; let blob_store = ObjectStoreFactory::new(object_store_config.0)