question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using lock and fetch throws "No value specified for parameter 7" sql exception

See original GitHub issue

Hey @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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kagkarlssoncommented, Mar 24, 2021

Fix released in v10.1

1reaction
kagkarlssoncommented, Mar 24, 2021

Very good to hear that the new polling strategy had such a significant effect! Thank you for taking time and giving feedback 🙇

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.sql.SQLException: No value specified for parameter 7
Code: String id = request.getParameter("id"); hms1 st = dao.getRecordById(Integer.parseInt( ...
Read more >
SQL error messages and exceptions - Oracle Help Center
All the arguments to the COALESCE/VALUE function cannot be parameters. The function needs at least one argument that is not a parameter. 42611,...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
MariaDB Error Codes
MariaDB shares error codes with MySQL, as well as adding a number of new error ... An SQLSTATE value, consisting of five characters,...
Read more >
SQLSTATE values and common error codes - IBM
Option not specified following the ALTER PARTITION CLAUSE. 01668, A rowset FETCH statement returned one or more rows of data, with one or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found