PlanetScale offers enhanced database connection management tools for Postgres and MySQL, including dashboard and CLI commands to inspect and terminate connections. This feature aims to prevent and resolve database downtime caused by unhandled exceptions, open transactions, and schema change locks. The post details how connection poolers like PgBouncer can lead to 'poisoned' pools due to stale session states, causing write errors. It introduces `DISCARD ALL` as a quick fix and recommends using `i` PgBouncer for all application traffic, with options for local, dedicated primary, and dedicated replica PgBouncers. The post details configuration options like `max_client_conn`, `default_pool_size`, `max_db_connections`, and `max_user_connections`, and provides tuning examples for small and large servers, as well as single-tenant configurations, to optimize connection pooling and prevent exceeding PostgreSQL's `max_connections`.
All PlanetScale trails