priderider
priderider

Reputation: 21

Spring Boot application using HikariCP and impossibl/pgjdbc-ng driver fails to connect to pgbouncer

we have implemented a spring-boot application using HikariCP and the impossibl/pgjdbc-ng driver. The application is running fine as long as the database connection url refers to a postgres database. However, when the database url contains the address of the pgbouncer the application fails to start with the following error message:

2021-11-24 09:26:36,575 ERROR [main]                            com.zaxxer.hikari.pool.HikariPool: 594 - Exception during pool initialization. {}
com.impossibl.postgres.jdbc.PGSQLSimpleException: Connection Error: prepared statement "TB" already exists
    at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:197)
    at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:134)
    at com.impossibl.postgres.jdbc.ConnectionUtil.createConnection(ConnectionUtil.java:326)
    at com.impossibl.postgres.jdbc.ConnectionUtil.createConnection(ConnectionUtil.java:279)
    at com.impossibl.postgres.jdbc.PGDriver.connect(PGDriver.java:104)
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
    at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)

...

I have found some recommendation to replace HikariCP by another datasource implementation to solve the problem, but this is not an option as we do not want to change our application. So my questions are:

  1. What is the cause of the error message?
  2. Is it possible to solve the problem by adding some parameter to the JDBC URL?

Thanks in advance!

Upvotes: 1

Views: 612

Answers (0)

Related Questions