MetaData Sync Issue

Hi All,

While performing metadata sync from one instance(2.40.4.1) to another(2.40.4.1), I am receiving below error

org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT count(instance) FROM ( SELECT TEI.uid AS instance, TEI.created AS created, TEI.lastupdated AS lastupdated, TEI.ou AS ou, TEI.ouname AS ouname, TET.uid AS te, TEI.inactive AS inactive, TEI.potentialduplicate AS potentialduplicate, TEI.deleted AS deleted FROM (SELECT DISTINCT TEI.trackedentityinstanceid, TEI.uid, TEI.created, TEI.lastupdated, TEI.inactive, TEI.trackedentitytypeid, TEI.potentialduplicate, TEI.deleted, OU.uid as ou, OU.name as ouname FROM trackedentityinstance TEI INNER JOIN program P ON P.trackedentitytypeid = TEI.trackedentitytypeid AND P.programid IN ()LEFT JOIN trackedentityprogramowner PO ON PO.trackedentityinstanceid = TEI.trackedentityinstanceid AND P.programid = PO.programid INNER JOIN organisationunit OU ON OU.organisationunitid = COALESCE(PO.organisationunitid, TEI.organisationunitid) where TEI.trackedentitytypeid in (215088) and TEI.lastupdated >= TEI.lastsynchronized AND TEI.lastupdated >= ‘1970-01-01T01:00:00.000’) TEI LEFT JOIN trackedentitytype TET ON TET.trackedentitytypeid = TEI.trackedentitytypeid ) teicount]; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near “)”

I could see data in Program and Tracked Entities table so I dont see a point of having P.programid IN (). Should there be something else I should also be looking at.

Help is highly appreciated

@dhis2-backend @dhis2-platform @dhis2-projects

Okay so the badsqlgrammerexception gets fixed when I add a Tracker Program.

Is that a constarint? If we only have Event Program shouldnt it work? I dont see that a list of violations in the code as well.

Again Am I missing on something.

@dhis2-projects @dhis2-backend @dhis2-platform

Hi @Vishwanideep_Kumar

Thank you for the details you shared, and welcome to the community!

So based on your explanation, when you create a Tracker Program in addition to everything else that was already in the system, the sync works? What happens now if you delete this program, does the error return?

Thanks!

Hi @Gassim

Good Day and thanks for your response.

Yes, when I remove the Tracker Program badsqlgrammerexception comes back.

1 Like

Does the other instance have any metadata as well? Does it have a tracker program there too?

FYI, I have just forwarded your case to the team and waiting for a response.

Thanks!

@Gassim

Yes, the other instance has the metadata but no tracker program there as well.

1 Like

Hi @Vishwanideep_Kumar
This seems to be a bug. Could you create a jira issue explaining this?
Thanks for reporting this.

1 Like

Hi @Ameen

Good Day and Thanks for the confirmation.

Sure, will raise a Jira for the same.

Hi @Vishwanideep_Kumar
I would like more details to be able to reproduce this

Does the remote server have both Tracker and Event programs or just Event programs? I understand that the local server has only Event Programs. Correct?

1 Like