Crowd Crashes Due to 'PSQLException: ERROR: prepared statement "S_1" does not exist'
Symptoms
Crowd crashes or can't be started due to the following error:
PSQLException: ERROR: prepared statement "S_1" does not exist
Cause
PgBouncer is used in transaction mode by default for all PostgreSQL connections, which breaks JDBC's default PREPARED STATEMENT handling.
Resolution
The ?prepareThreshold=0 argument must be used on Crowd string connection configured in the crowd.cfg.xml file located under <crowd-home>/crowd.cfg.xml. Example:
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/dbname?prepareThreshold=0</property>
This will show on the starting Crowd logs:
jdbcUrl -> jdbc:postgresql://localhost:5432/dbname?prepareThreshold=0, properties -> {user=******, password=******} ],
If the issue persists after setting the parameter, you'll need to update the PostgreSQL JDBC4 driver used to 9.3 or newer due to this PgSQL bug: http://pgbouncer.projects.pgfoundry.org/doc/faq.html#_disabling_prepared_statements_in_jdbc
- JDBC4 download link: https://jdbc.postgresql.org/download.html
Move the driver to <crowd-install>/apache-tomcat/lib and make sure to remove older JDBC driver from that directory before restarting your Crowd instance.
This procedure should work with other Atlassian tools that present this issue too.