Using lock and fetch throws "No value specified for parameter 7" sql exception
See original GitHub issueHey @kagkarlsson!
Hope you’re well - using your fantastic library at my new place and I saw that version 10.0 includes the pollUsingLockAndFetch
so wanted to test it out.
Anyway, end up getting a weird exception only in production:
org.postgresql.util.PSQLException: No value specified for parameter 7.
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:270)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:159)
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:148)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
at com.github.kagkarlsson.jdbc.JdbcRunner.lambda$execute$2(JdbcRunner.java:85)
at com.github.kagkarlsson.jdbc.JdbcRunner.withConnection(JdbcRunner.java:140)
at com.github.kagkarlsson.jdbc.JdbcRunner.execute(JdbcRunner.java:66)
at com.github.kagkarlsson.jdbc.JdbcRunner.query(JdbcRunner.java:62)
at com.github.kagkarlsson.scheduler.jdbc.PostgreSqlJdbcCustomization.lockAndFetch(PostgreSqlJdbcCustomization.java:58)
at com.github.kagkarlsson.scheduler.jdbc.AutodetectJdbcCustomization.lockAndFetch(AutodetectJdbcCustomization.java:87)
at com.github.kagkarlsson.scheduler.jdbc.JdbcTaskRepository.lockAndGetDue(JdbcTaskRepository.java:157)
at com.github.kagkarlsson.scheduler.LockAndFetchCandidates.run(LockAndFetchCandidates.java:75)
at com.github.kagkarlsson.scheduler.RunUntilShutdown.run(RunUntilShutdown.java:40)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.lang.Thread.run(Thread.java:832)
com.github.kagkarlsson.jdbc.SQLRuntimeException: org.postgresql.util.PSQLException: No value specified for parameter 7.
at com.github.kagkarlsson.jdbc.JdbcRunner.translateException(JdbcRunner.java:126)
at com.github.kagkarlsson.jdbc.JdbcRunner.lambda$execute$2(JdbcRunner.java:93)
at com.github.kagkarlsson.jdbc.JdbcRunner.withConnection(JdbcRunner.java:140)
at com.github.kagkarlsson.jdbc.JdbcRunner.execute(JdbcRunner.java:66)
at com.github.kagkarlsson.jdbc.JdbcRunner.query(JdbcRunner.java:62)
at com.github.kagkarlsson.scheduler.jdbc.PostgreSqlJdbcCustomization.lockAndFetch(PostgreSqlJdbcCustomization.java:58)
at com.github.kagkarlsson.scheduler.jdbc.AutodetectJdbcCustomization.lockAndFetch(AutodetectJdbcCustomization.java:87)
at com.github.kagkarlsson.scheduler.jdbc.JdbcTaskRepository.lockAndGetDue(JdbcTaskRepository.java:157)
at com.github.kagkarlsson.scheduler.LockAndFetchCandidates.run(LockAndFetchCandidates.java:75)
at com.github.kagkarlsson.scheduler.RunUntilShutdown.run(RunUntilShutdown.java:40)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.lang.Thread.run(Thread.java:832)
Here’s my config:
Scheduler
.create(configureDataSource(dataSource))
.tableName(TABLE_NAME)
.pollingInterval(Duration.ofMillis(50))
.heartbeatInterval(Duration.ofSeconds(30))
.shutdownMaxWait(Duration.ofMinutes(1))
.threads(THREADS)
.executorService(executor)
.startTasks(toTasks(jobs))
.pollUsingLockAndFetch(0.5, 1.0)
.build();
build.gradle
implementation 'com.github.kagkarlsson:db-scheduler:10.0'
implementation 'org.postgresql:postgresql:42.2.19'
I’m running postgres version 12.5 on AWS RDS.
From the stacktrace it seems to be throwing an error here: https://github.com/kagkarlsson/db-scheduler/blob/1d9139c42397562dd5c4cd793363eabdc84f762e/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/PostgreSqlJdbcCustomization.java#L47-L70
I re-read the query a few times and as far as I can tell there seems to be six params there so I’m not sure sure where postgres is getting the 7th param from?
Anyway - would be great to get it working so let me know if you need anything else from my side!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Fix released in v
10.1
Very good to hear that the new polling strategy had such a significant effect! Thank you for taking time and giving feedback 🙇