[issue] Metadata Import fails when modifying a tracker program and tracker program stage

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])

  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])

  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])

  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

···

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

Hi Archana!

I’ll let Morten or someone else comment on possible fixes, but recently had the same problem as you describe in “with registration” below. I didn’t dig to the bottom of it but found a workaround: You can manually clean out the program_attribute rows connected to the program(s) being imported.

delete from program_attributes where programid = ;

The second problem you describe you should be able to work around in the same way, but then cleaning out the programstagedataelements entries for your program(s).

delete from programstagedataelement where programstageid in(select programstageid from programstage where programid = );

If trying this workarounds you should back up your db first.

Markus

···

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

Hi Archana

I’m looking into this now.

···

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

This should be fixed in latest 225/master (2.24 was not affected)

···

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m looking into this now.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Hi Morten,

Thanks for the fix. We’re now able to import Program Stage of a Tracker program after modifying it.

But, the issue still exists while importing a modified Tracker program.

Please find the log trace attached herewith.

Cheers,

Importing_program_fails.log (17 KB)

···

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

This should be fixed in latest 225/master (2.24 was not affected)

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m looking into this now.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Hi Archana

Ok, looking into it now…

···

On Thu, Nov 10, 2016 at 12:39 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi Morten,

Thanks for the fix. We’re now able to import Program Stage of a Tracker program after modifying it.

But, the issue still exists while importing a modified Tracker program.

Please find the log trace attached herewith.

Cheers,

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

This should be fixed in latest 225/master (2.24 was not affected)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m looking into this now.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Hi Archana

I’m not able to reproduce this issue. Could you provide a bit more info? steps to reproduce.

···

On Thu, Nov 10, 2016 at 12:52 PM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

Ok, looking into it now…

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Nov 10, 2016 at 12:39 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi Morten,

Thanks for the fix. We’re now able to import Program Stage of a Tracker program after modifying it.

But, the issue still exists while importing a modified Tracker program.

Please find the log trace attached herewith.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

This should be fixed in latest 225/master (2.24 was not affected)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m looking into this now.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Hi Morten,

Here are the steps to reproduce:

  1. Create a program “with registration”.

  2. Create a program Stage within it.

  3. Export and Import this metadata into another instance.

  4. Import is successful

  5. Now, modify some property of the Program in the first instance (e.g: name, description etc)

  6. Export and Import (i.e Sync metadata)

  7. Import Fails with the error mentioned in the logs attached in previous mail.

P.S. We’re using DHIS version 2.25 build 1ce40ae.

Cheers,

···

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

On Thu, Nov 10, 2016 at 11:47 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m not able to reproduce this issue. Could you provide a bit more info? steps to reproduce.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Nov 10, 2016 at 12:52 PM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

Ok, looking into it now…

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Nov 10, 2016 at 12:39 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi Morten,

Thanks for the fix. We’re now able to import Program Stage of a Tracker program after modifying it.

But, the issue still exists while importing a modified Tracker program.

Please find the log trace attached herewith.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

This should be fixed in latest 225/master (2.24 was not affected)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m looking into this now.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Hm ok, that’s basically what I did… but I will test again tomorrow

···

On Thu, Nov 10, 2016 at 4:40 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi Morten,

Here are the steps to reproduce:

  1. Create a program “with registration”.
  1. Create a program Stage within it.
  1. Export and Import this metadata into another instance.
  1. Import is successful
  1. Now, modify some property of the Program in the first instance (e.g: name, description etc)
  1. Export and Import (i.e Sync metadata)
  1. Import Fails with the error mentioned in the logs attached in previous mail.

P.S. We’re using DHIS version 2.25 build 1ce40ae.

Cheers,

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

On Thu, Nov 10, 2016 at 11:47 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m not able to reproduce this issue. Could you provide a bit more info? steps to reproduce.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Nov 10, 2016 at 12:52 PM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

Ok, looking into it now…

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Nov 10, 2016 at 12:39 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi Morten,

Thanks for the fix. We’re now able to import Program Stage of a Tracker program after modifying it.

But, the issue still exists while importing a modified Tracker program.

Please find the log trace attached herewith.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

This should be fixed in latest 225/master (2.24 was not affected)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Nov 9, 2016 at 10:14 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Archana

I’m looking into this now.

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Nov 4, 2016 at 4:07 PM, Archana Chillala archanac@thoughtworks.com wrote:

Hi,

We are using the latest version of DHIS 2.25 (build - 5e16867). We have two instances of DHIS and are trying to sync metadata from one instance to the other. Sync is failing for the following cases.

**Modifying a Tracker program (i.e. program “with registration”) **

  • INFO 2016-11-02 16:36:27,877 (admin) Creating 1 object(s) of type ProgramTrackedEntityAttribute (DefaultObjectBundleService.java [http-bio-8080-exec-7])
  • WARN 2016-11-02 16:36:27,902 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,903 ERROR: duplicate key value violates unique constraint "programtrackedentityattribute_unique_key"

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists. (SqlExceptionHelper.java [http-bio-8080-exec-7])

* ERROR 2016-11-02 16:36:27,916 Exception occurred while trying to import the metadata. could not execute statement (MetadataSyncImportHandler.java [http-bio-8080-exec-7])

org.hibernate.exception.ConstraintViolationException: could not execute statement

at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2921)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “programtrackedentityattribute_unique_key”

Detail: Key (programid, trackedentityattributeid)=(80, 74) already exists.

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)

at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)

at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Modifying the program stage of a Tracker program (i.e. program “with registration”)

  • INFO 2016-11-02 16:55:26,050 (admin) Updating 1 object(s) of type ProgramStage (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • INFO 2016-11-02 16:55:26,065 (admin) Updating 2 object(s) of type ProgramStageDataElement (DefaultObjectBundleService.java [http-bio-8080-exec-10])
  • ERROR 2016-11-02 16:55:26,073 Exception occurred while trying to import the metadata. Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 (MetadataSyncImportHandler.java [http-bio-8080-exec-10])

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:46)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3106)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365)

at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)

at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)

at com.sun.proxy.$Proxy186.commit(Unknown Source)

Could you please help fix the issues.

Cheers,

Archana Chillala
Application Developer
Email
archanac@thoughtworks.com
Telephone
+91 9100960533
ThoughtWorks


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp