Skip to content

[FEATURE]: Add Configurable Database Connection Pool Limits #148

@minikill

Description

@minikill

Problem

The application currently hardcodes database connection pool settings (SetMaxOpenConns(10)), which can cause issues in certain environments:

  1. Managed databases with connection limits (e.g., DigitalOcean) may have strict connection quotas
  2. lib/pq driver prepared statement conflicts: With connection pooling, users experience "pq: unnamed prepared statement does not exist" errors, especially on managed PostgreSQL instances (unnamed prepared statement does not exist ERROR on production/staging servers lib/pq#889)
  3. No way to tune performance based on deployment environment

Ideal Solution (Long-term)

Switch to a more modern PostgreSQL driver that properly handles prepared statements with connection pooling, such as:

  • pgx - Actively maintained with better connection pooling support
  • pgxpool - Built specifically for connection pooling scenarios

Proposed Short-term Workaround

Add environment variables to make connection pool settings configurable:

  • PBW_DB_MAX_CONNS (default: 10)
  • PBW_DB_MAX_IDLE_CONNS (default: 5)

This allows users to:

  • Limit connections to match their database plan
  • Set to 1 connection to work around lib/pq prepared statement issues
  • Tune for their specific workload

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions