Skip to content

Commit 06263bc

Browse files
authored
[CLI] Increase max_connections for postgres in local testnet (aptos-labs#12473)
1 parent 0d6829d commit 06263bc

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

crates/aptos/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
All notable changes to the Aptos CLI will be captured in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format set out by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44

55
## Unreleased
6+
- Increased `max_connections` for postgres container created as part of local testnet to address occasional startup failures due to overloaded DB.
67

78
## [3.0.1] - 2024/03/05
89
- Fix bug in `aptos update revela` if default install directory doesn't exist.

crates/aptos/src/node/local_testnet/postgres.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use tracing::{info, warn};
2525

2626
pub const POSTGRES_CONTAINER_NAME: &str = "local-testnet-postgres";
2727
const POSTGRES_VOLUME_NAME: &str = "local-testnet-postgres-data";
28-
const POSTGRES_IMAGE: &str = "postgres:14.9";
28+
const POSTGRES_IMAGE: &str = "postgres:14.11";
2929
const DATA_PATH_IN_CONTAINER: &str = "/var/lib/mydata";
3030
const POSTGRES_DEFAULT_PORT: u16 = 5432;
3131

@@ -271,6 +271,23 @@ impl ServiceManager for PostgresManager {
271271
// directory inside the container that is mounted from the host system.
272272
format!("PGDATA={}", DATA_PATH_IN_CONTAINER),
273273
]),
274+
cmd: Some(
275+
vec![
276+
"postgres",
277+
"-c",
278+
// The default is 100 as of Postgres 14.11. Given the local testnet
279+
// can be composed of many different processors all with their own
280+
// connection pools, 100 is insufficient.
281+
"max_connections=200",
282+
"-c",
283+
// The default is 128MB as of Postgres 14.11. We 2x that value to
284+
// match the fact that we 2x'd max_connections.
285+
"shared_buffers=256MB",
286+
]
287+
.into_iter()
288+
.map(|s| s.to_string())
289+
.collect(),
290+
),
274291
..Default::default()
275292
};
276293

crates/aptos/src/node/local_testnet/processors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ impl ProcessorManager {
9898
ending_version: None,
9999
number_concurrent_processing_tasks: None,
100100
enable_verbose_logging: None,
101-
db_pool_size: None,
101+
// The default at the time of writing is 30 but we don't need that
102+
// many in a local testnet environment.
103+
db_pool_size: Some(8),
102104
gap_detection_batch_size: 50,
103105
};
104106
let manager = Self {

0 commit comments

Comments
 (0)