Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails, PgBouncer and DigitalOcean — how to work with Databases Connection Pools?

Recently in DigitalOcean has the opportunity to create Databases. This is something like a turnkey solution based on the usual Droplet with a bunch of additional database features.

One of these additional features — Connection Pools. As far as I understand this is a PgBouncer.

If I connect the database to the Rails 5.2 application in the usual way (directly), then everything is fine.

But if I use the connection through the "Connection Pools", I will get an error:

ActiveRecord::StatementInvalid: PG::DuplicatePstatement: ERROR: prepared statement "a1" already exists

This will occur when any data is received from the database.

Tell me, please, how to make it all work?

like image 387
Colibri Avatar asked Dec 11 '22 02:12

Colibri


1 Answers

Set prepared_statements and advisory_locks to false in the database configurations.

More info here.

like image 119
Husam Bilal Avatar answered Apr 08 '23 11:04

Husam Bilal