ERROR/ cannot execute nextval() in a read-only transaction

Hello,

When trying to enter data in some of our datasets we’re having errors to save the data and the box turn to red. In the logs we are having errors related to the query in to the database. See logs :
We’re on DHIS2 Version 2.35.6

 * INFO  2021-11-08T08:09:36,657 'admin' create org.hisp.dhis.period.Period, name: 2021Q4, uid: 2021Q4 (AuditLogUtil.java [http-nio-8080-exec-4])
dhis2-web_1        |  * WARN  2021-11-08T08:09:36,663 SQL Error: 0, SQLState: 25006 (SqlExceptionHelper.java [http-nio-8080-exec-4])
dhis2-web_1        |  * ERROR 2021-11-08T08:09:36,664 ERROR: cannot execute nextval() in a read-only transaction (SqlExceptionHelper.java [http-nio-8080-exec-4])
dhis2-web_1        |  * ERROR 2021-11-08T08:09:36,669 Error while executing action (ExceptionInterceptor.java [http-nio-8080-exec-4])
dhis2-web_1        |    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:1471) ~[c3p0-0.9.5.5.jar:0.9.5.5]
dhis2-web_1        |    at dhis2-web_1        | Caused by: org.postgresql.util.PSQLException: ERROR: cannot execute nextval() in a read-only transaction
dhis2-web_1        |    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) ~[postgresql-42.2.5.jar:42.2.5]
dhis2-web_1        |    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:1471) ~[c3p0-0.9.5.5.jar:0.9.5.5]
dhis2-web_1        |    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
dhis2-web_1        |    ... 212 more

I would appreciate if some one could help to solve this issue.

Thanks

1 Like

I think that there’s a jira bug issue reported by @Gintare that might be similar to the issue you are facing: DHIS2-11856 | Internal server error when posting data values . I’d need a confirmation from you or @Gintare if it’s the same issue.

If it’s not would you please write steps to reproduce and maybe screenshot of the console (network tab) while trying to save the data so that we get the API request. Thank you! (:

1 Like

Resolved by running . select nextval (‘hibernate_sequence’); once directly in the database.

3 Likes

Thank you for sharing the solution @diallotafsir52! (:

Hello I’m facing the same problem kindly give more details on how I can resolve it.

Hello, I also would be interested in more detail. I am having the same problem.