:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
perf(propdefs): connect the API pool lazily (#79316)
Eli Reismanb60afb6f6391
diff --git a/rust/property-defs-rs/src/main.rs b/rust/property-defs-rs/src/main.rsindex 1854c809d359..73724c4464cd 100644--- a/rust/property-defs-rs/src/main.rs+++ b/rust/property-defs-rs/src/main.rs@@ -95,9 +95,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {let consumer = SingleTopicConsumer::new(config.kafka.clone(), config.consumer.clone())?;// Dedicated PG conn pool for serving propdefs API queries only. The API is mounted but- // receives no production traffic today.- let options = PgPoolOptions::new().max_connections(config.max_pg_connections);- let api_pool = options.connect(&config.database_url).await?;+ // receives no production traffic today, so connect lazily: `connect` would open a connection+ // at startup and hold it idle for a surface nothing calls, and would also make boot depend on+ // Postgres being reachable. The first request pays the connect cost instead.+ let api_pool = PgPoolOptions::new()+ .max_connections(config.max_pg_connections)+ .connect_lazy(&config.database_url)?;let query_manager = QueryManager::new(api_pool).await?;let context = Arc::new(AppContext::new(&config, query_manager).await?);