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

Hi all devs,

Our devs are having an error with an local app written in Javascript. The error received is “ERROR: cannot execute nextval() in a read-only transaction”

War in which the error does not appear:
Version:
2.30
Build revision:
2ecc8ef
Build date:
2019-03-18 02:06

But receiving errors on these 2 separate war files with our app and our instance:
Version:
2.30
Build revision:
21e635b
Build date:
2019-08-14 02:06

Version:
2.30
Build revision:
345003b
Build date:
2019-08-28 02

Strangely though on the last war file, we tested in Play demo on 2.30 and latest 2.32.1 and did not get the same error. However the stack overflow posts below seems to explain why.

The log file error says:

  • WARN 2019-08-28 08:30:43,163 HHH000104: firstResult/maxResults specified with collection fetch; applying in memory! (QueryTranslatorImpl.java [http-nio-8080-exec-4])
  • WARN 2019-08-28 08:30:43,189 SQL Error: 0, SQLState: 25006 (SqlExceptionHelper.java [http-nio-8080-exec-4])
  • ERROR 2019-08-28 08:30:43,190 ERROR: cannot execute nextval() in a read-only transaction (SqlExceptionHelper.java [http-nio-8080-exec-4])
  • WARN 2019-08-28 08:30:43,192 Resolved [org.hibernate.exception.GenericJDBCException: could not extract ResultSet] (AbstractHandlerExceptionResolver.java [http-nio-8080-exec-4])

We have found Stack overflow posts

It seems that this is related to Spring addressing Postgres using an insert in what is a read-only transaction and thus likely a bug either in Spring or in the DHIS which needs to mark the transaction as read-write (possibly as a work-around).

Can someone please confirm how this can be addressed.

2 Likes

Hi,

Just to add, this error also affect the Tracker capture app that we cannot query a Tracked Entity Instance.

Regards,

Elmarie

1 Like