How to change the postgresql.conf parameter on Google Cloud SQL
Asked Answered
Q

2

9

How to change the postgresql.conf parameter "max_connections" on Google Cloud SQL?

When I exceed 100 connections I get the error: "FATAL: remaining connection slots are reserved for non-replication superuser connections"

Queensland answered 1/6, 2017 at 0:34 Comment(1)
You're usually better off putting a connection pooler like pgbouncer in front. Surprised they don't do that automatically.Madagascar
R
9

Normally you would do it via CloudSQL flags API (or UI): https://cloud.google.com/sql/docs/postgres/flags

However, max_connections is not a parameter we currently support. We (Postgres team in CloudSQL) are aware that low max_connections is a problem for some (many?) applications and will address issue in one of the next releases.

Please follow issue 37271935 on our public issue tracker for updates.

Rapprochement answered 1/6, 2017 at 15:46 Comment(0)
M
1

Years later, it seems like it's supported now.

For the Terraform gang, you can update the parameter this way:

resource "google_sql_database_instance" "main" {
  name             = "main-instance"
  database_version = "POSTGRES_14"
  region           = "us-central1"

  settings {
    tier = "db-f1-micro"

    database_flags {
      name  = "max_connections"
      value = 100
    }
  }
}

Note that at the time of writing the db-f1-micro default max_connections is 25, refs https://cloud.google.com/sql/docs/postgres/flags#postgres-m

Minetta answered 19/11, 2022 at 21:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.