Problem:
Users encounter startup errors when trying to run Terraform Enterprise (TFE) with PgBouncer enabled on Azure Database for PostgreSQL Flexible Server.
Cause:
- Failed retrieving database version: ERROR: unnamed prepared statement does not exist (SQLSTATE 26000)
- Failed to check if table exists: error finding application_versions table: ERROR: unnamed prepared statement does not exist (SQLSTATE 26000)
Solutions:
- Temporarily bypass PgBouncer by connecting directly to PostgreSQL on port 5432.
- Confirm that TFE operates correctly without PgBouncer. This helps isolate the problem to PgBouncer.
- If using prepared statements, ensure PgBouncer is configured to handle them correctly. Consider setting pgbouncer.max_prepared_statements to a non-zero value.
- Review the connection string used by TFE and ensure it points to PgBouncer on port 6432.
Example Connection String:
psql "host=myPgServer.postgres.database.azure.com port=6432 dbname=tfedb user=tfeappadmin password=xxxxxxx sslmode=require"
Outcome:
- Confirm that TFE starts without errors when connecting directly to PostgreSQL.
-
If TFE fails with PgBouncer, further troubleshooting or alternative approaches may be necessary
depending on the use case or workflow with PgBouncer and TFE.