I need help upgrading DHIS2 from version 2.29 to 2.30

I have upgraded my DHIS2 from 2.27 to 2.29 but when I try to upgrade to 2.30, I do not see any data. I tried the upgrade process and everything (data element, org units etc.) are available but the actual event data does not show. I opened analytics and started it and get an error about creating duplicate values.
I have also tried import/export and brought over everything but the data is not showing and when I run analytics i get the same sql error about inserting/creating duplicates.

Can someone help me.

2.30 is good start but you’ll need much more effort to reach a supported version
I guess you had data quality issue or missing constraint in the history of this server.

Can you share the exact error message when you launched the analytics process so we can help you more ?

(I already saw in past a lot of issues around categoryCombo with several “default”)

Here is the error plus the log from apache
Error.doc (20.4 KB)

so you get duplicate for the period 1993-02-06

ERROR 2024-09-04 13:26:20,646 Analytics table process failed: org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [insert into _dateperiodstructure_temp values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)]; ERROR: duplicate key value violates unique constraint "_dateperiodstructure_temp_pkey"
  Detail: Key (dateperiod)=(1993-02-06) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "_dateperiodstructure_temp_pkey"
  Detail: Key (dateperiod)=(1993-02-06) already exists.

First make sure you are upgrading to the lastest 2.30 patch ?

I guess it’s not in the aggregate model ?

but you can verify with a query like this

select * from period where startdate = '1993-02-06' or enddate = '1993-02-06'

if it’s in the tracker or event model then it’s probably more a bug in the code.

I don’t remember if it’s available in 2.30 but normally there’s a maintenance task to delete all these _
 tables or running the period/ressources tables generation separately

I would search the jira or this forum about similar issue.
or ask @Gassim

1 Like

I found a few entries

but no clear solution sadly

1 Like

Thanks Stephan.

It must be a bug because I did a fresh instance with no data and got the same error when I ran analytics. Second my data was entered from 2019 but it is showing 1993 as the date period. And there is no patch for it.

Dear @Collin.Dosunmu,

if you run this SQL “select * from categoryoptioncombo where name like ‘default’;” and find out that you have two defaults then that may be the contributing factor as @Stephan_Mestach mentioned.

1 Like

Thanks Daniel,

I ran the SQL and it returned only one default so I can rule it out as a source of my problem. I do not have any data yet if I run the Analytics, I still get the error. I saw someone mention something about the time/ time zone. Do you know if this could be an issue?

Hi

What version of DHIS2 was the instance you used to test this?

Would it be possible if you please try to upgrade to one of the latest supported versions instead of 2.30?

Thank you!

Hi! My problem is I am trying to upgrade to the latest from version 2.27 but in order to do so I have to upgrade to 2.28 then 2.29 then 2.30 and then I can upgrade to which version I want. I can upgrade to version 2.29 and still have all my data working but once I upgrade to 2.30 I cannot access the data.

1 Like

Upgrading DHIS2 from older versions to the latest requires careful planning and an incremental approach

Please share your catalina.out logs here so we can address the issues one by one. Additionally, focus on cleanup and database preparation as these are crucial steps in the upgrade process.

based on my practices please ensure following steps:
you can refer to the

  1. Initial Cleanup:
  • Remove unnecessary logs and error logs.
  • Drop materialized views and clear analytics data.
  1. Database Preparation:
  • Keep only essential datasets, metadata, and transactional data. Exclude logs or deleted data.
  1. Incremental Upgrades (Version-by-version).
  2. Post-Upgrade:
  • Regenerate materialized views and analytics tables.
  • Test accuracy in programs, reports, and dashboards.
  1. Testing and Verification:
  • Run test scripts and verify key modules.
  • Check compatibility of custom apps, APIs, and integrations.

Another potential solution is to install a fresh DHIS2 latest instance instance and manually import the metadata and data, if feasible. However, without knowing the size of your data, I can’t fully recommend this approach.

1 Like

Thank you for your response. I removed all the SQL views and that solved the problem. I can now view my data in versions 2.29 and 2.30

1 Like