Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepared statement already exists #589

Open
kcbanner opened this issue Jun 30, 2023 · 0 comments
Open

Prepared statement already exists #589

kcbanner opened this issue Jun 30, 2023 · 0 comments

Comments

@kcbanner
Copy link

 com.impossibl.postgres.jdbc.PGSQLSimpleException: prepared statement "cached-b87c258b" already exists
         at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:197) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:174) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:161) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGDirectConnection.execute(PGDirectConnection.java:514) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGPreparedStatement.lambda$parseIfNeeded$3(PGPreparedStatement.java:289) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGDirectConnection.getCachedPreparedStatement(PGDirectConnection.java:1608) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGPreparedStatement.parseIfNeeded(PGPreparedStatement.java:284) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGPreparedStatement.execute(PGPreparedStatement.java:329) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:357) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:106) ~[pgjdbc-ng-0.8.9.jar:0.8.9]
         at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-3.3.1.jar:?]
         at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-3.3.1.jar:?]
         at com.j256.ormlite.jdbc.JdbcCompiledStatement.runQuery(JdbcCompiledStatement.java:66) ~[ormlite-jdbc-5.7.jar:?]
         at com.j256.ormlite.stmt.SelectIterator.<init>(SelectIterator.java:56) ~[ormlite-core-5.7.jar:?]
         at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:254) ~[ormlite-core-5.7.jar:?]
         at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:203) ~[ormlite-core-5.7.jar:?]
         at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:282) ~[ormlite-core-5.7.jar:?]
         at com.j256.ormlite.stmt.QueryBuilder.query(QueryBuilder.java:384) ~[ormlite-core-5.7.jar:?]
         at com.j256.ormlite.stmt.Where.query(Where.java:517) ~[ormlite-core-5.7.jar:?]

... snip ...

I have a query that for only particular users, hits this exception. The cache key is always the same, and it's always on the same query.

The query itself is built as follows:

		List<ManufacturingJobResult> manufacturingJobResults = database
		  .getManufacturingJobResultDao()
		  .queryBuilder()
		  .orderBy("completeddate", true)
		  .where()
		  .eq("producttypeid", requiredTypeId)
		  .and()
		  .in("characterid", characterIds)
		  .and()
		  .lt("completeddate", beforeDate)
		  .and()
		  .raw("(quantity_sold + quantityconsumed) < quantity")
		  .and()
		  .eq("materialsincomplete", false)
		  .query();

It seems that something is going wrong in the caching layer - but I'm not sure how to properly debug this. Is this just an unlucky hash collision?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant