How about read only replicat?

I have setup two replicate of DHIS2 DB USING RepMgr .dhis2 can work fine for comment out the replica conf in dhis.conf.

but can’t finish the data analysis with replica opened. seem DHIS2 write another replica db.
why?

(DataHandler.java [http-nio-38080-exec-5]) ID2+S8sCJW+APg7I5dj0Dseivz7NfEUeH9AWYBU4ORi7Q=

  • ERROR 2025-11-10T20:51:58,699 java.lang.Exception (CrudControllerAdvice.java [http-nio-38080-exec-5]) ID2+S8sCJW+APg7I5dj0Dseivz7NfEUeH9AWYBU4ORi7Q=
    org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [select ax.“dx”,ax.“monthly”, sum(value) as value from (select ap.* from analytics_2024 as ap union all select ap.* from analytics_2025 as ap ) as ax where ax.“dx” in (‘wm9Ldf8V5pp’) and ax.“monthly” in (‘202411’, ‘202412’, ‘202501’, ‘202502’, ‘202503’, ‘202504’, ‘202505’, ‘202506’, ‘202507’, ‘202508’, ‘202509’, ‘202510’) and ( ax.“uidlevel1” in (‘pJ0C3w6gmrK’) ) and ax.“year” in (2024, 2025) group by ax.“dx”,ax.“monthly” ]; SQL state [0A000]; error code [0]; ERROR: cannot access temporary or unlogged relations during recovery
    at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1557)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:408)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:476)
    at org.springframework.jdbc.core.JdbcTemplate.queryForRowSet(JdbcTemplate.java:541)
    at org.hisp.dhis.analytics.data.JdbcAnalyticsManager.getKeyValueMap(JdbcAnalyticsManager.java:939)
    at org.hisp.dhis.analytics.data.JdbcAnalyticsManager.lambda$getAggregatedDataValues$1(JdbcAnalyticsManager.java:201)
    at org.hisp.dhis.analytics.util.AnalyticsUtils.withExceptionHandling(AnalyticsUtils.java:1244)
    at org.hisp.dhis.analytics.util.AnalyticsUtils.withExceptionHandling(AnalyticsUtils.java:1230)
    at org.hisp.dhis.analytics.data.JdbcAnalyticsManager.getAggregatedDataValues(JdbcAnalyticsManager.java:201)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:114)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at java.base/java.lang.Thread.run(Thread.java:1589)
    Caused by: org.postgresql.util.PSQLException: ERROR: cannot access temporary or unlogged relations during recovery
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2734)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2421)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:372)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:518)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:435)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:357)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:342)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:318)
    at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:267)
    at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:111)
    at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java)
    at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:463)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:393)
    … 15 more

Hi @linxd

May I ask what is the goal of the replica? Are you trying to create a back-up of the instance? There are automated scripts to creating backups, for example, you can check out: dhis2-server-tools/deploy/roles/backups/templates at cfaaed03920c80eb8a77388a9652f3d698fb15dc · dhis2/dhis2-server-tools · GitHub

more help?
unsuccessful

Hi @linxd

I’m happy to help to the best that I can, but probably when this is triaged, experts will also need more information. Could you follow-up with the question above: