Skip to content

Add a new PgBouncer instance

Here the link to the video of the runbook simulation.

Adding PgBouncer instances might be necessary for special tasks such as rolling upgrades, or in case we reach organic saturation (for more details regarding monitoring and troubleshooting of PgBouncer connections see this runbook. For saturation spawning from abuse or other incidents see this runbook). You’ll ned to take into consideration what kind of PgBouncer instance node you want to create:

Read/write nodes manage requests to the patroni cluster leader, and are deployed in their own VMs. There’s two kind:

To add a new read/write node:

Read-only PgBouncers live on the secondary patroni nodes. Adding additional PgBouncer processes can be done via the chef-repo. You’ll need to make the following adjustments:

  • On roles/gprd-base-db-patroni.json:
  • On roles/gprd-base-db-pgbouncer-common.json:
    • Add the new systemd service under gitlab-server.systemd_service_overrides

See https://ops.gitlab.net/gitlab-cookbooks/chef-repo/-/merge_requests/2159 for a reference MR (though notice that we don’t need to do the prometheus changes anymore).

  • Merge and apply the chef-repo changes.

  • Run chef-client on the targeted hosts.

  • Make sure that pgbouncer can establish a connection to the secondary database:

    $ sudo pgb-console-[n]
    pgbouncer=# SHOW STATS;

    where n is the index corresponding to the ports you added on gitlab-pgbouncer.listening_ports (e.g. pgb-console-3 if you added a fourth port). You should see an entry for the gitlabhq_production database. If you added multiple ports check the pgb-console for each of them.

Unless you intentionally want to increase the amount of underlying connections to the database, you’ll need to adjust the pool_size attribute in the relevant chef-repo recipe to maintain the current settings. For example, if pool_size for the specific type of PgBouncer you’re creating is 40 and there’s currently 3 PgBouncers, then the total amount of connections is 120. To add a 4th PgBouncer while maintaining that amount, pool_size should be 30.