Sync Module Bug Blog

This page is a generic place to make a note of sync bugs encountered, and how the bug was cleared.  The idea now is just to get to this page started... as it becomes larger, we will have to work on better organization.

BUG: Sync record fails to import because on a parent server, a record containing an obs is generated before the record for the owning encounter. 

DIAGNOSIS: Error message in logs on child server similar to the following:

ERROR - HibernateSyncDAO.processCollection(1191) |2012-06-20 15:58:59,800| Cannot retrieve the collection's owner object.
ERROR - HibernateSyncDAO.processCollection(1192) |2012-06-20 15:58:59,801| Owner info:
ownerClassName:org.openmrs.Encounter
ownerCollectionPropertyName:obs
ownerCollectionAction:update
ownerUuid:d29a071d-4839-4cc2-8056-666bf4f8ec0dERROR - HibernateSyncDAO.processCollection(1191) |2012-06-20 15:58:59,800| Cannot retrieve the collection's owner object.

CAUSE: Unknown... underlying sync issue still needs to be researched.

SOLUTION: To clear the error, mark the offending obs record(s) to be ignored against all child servers.  Then on the parent server, go to the encounter and edit all the obs. (An easy way to do this is simply to add an edit comment like "fixing sync issue" without actually making any changes to obs itself).  This will cause a new sync record to be generated with the obs data.  Confirm that this record (or records) syncs, and then confirm through the ui that the encounter + obs are identical on both parent and child.

BUG: Maximum Retry Count Reached, Will No Longer Retry

DIAGNOSIS: The server has attempted to send the sync record too many times and is giving up.

CAUSE: The receiving server is encountering an error when importing that record.

SOLUTION:

  1. Check the server logs of the server receiving that record. Try to fix according to error message in server log.

  2. Increase the "retry limit" for the first server temporarily so that the records are attempted to send again                                                                                                                                                                                                                               

___

BUG: Sync record fails to import because somehow on the server the record was created on, the user (..creator of the record) got replaced after the sync record was created and the UUID for the user in the sync record screen doesn't seem to exist.

DIAGNOSIS: This example shows an Error message in logs on parent server when a user on the child (..who exists also on the parent) has created a patient, and Sync replaced his uuid when the sync record was created

ERROR - SyncIngestServiceImpl.processOpenmrsObject(562) |2013-02-20 10:18:23,380| Unexpected exception occurred while saving openmrsobject: org.openmrs.Patient, uuid 'c62287c2-f645-44ce-92c2-bcb6d3074d52'
ERROR - SyncIngestServiceImpl.processSyncRecord(298) |2013-02-20 10:18:23,382| Unable to ingest a sync request
org.openmrs.module.sync.ingest.SyncIngestException: Could not save item for unknown reasons - could not insert: [org.openmrs.Patient]
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processOpenmrsObject(SyncIngestServiceImpl.java:563)
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncItem(SyncIngestServiceImpl.java:423)
at sun.reflect.GeneratedMethodAccessor1145.invoke(Unknown Source)

...down the stack trace

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'creator' cannot be null
at sun.reflect.GeneratedConstructorAccessor304.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

CAUSE: Unknown...

SOLUTION: For this example, identify the real creator of the record first and then from the sync record screen, replace the UUID for the openmrs user with the correct uuid and try and resend the record.

____

BUG: Sync record fails to import on the a server because the record contains a relationship and one person in the relationship is missing in the current sever database.

DIAGNOSIS: Error message in logs on the receiving server similar to the following:

ERROR - SyncIngestServiceImpl.processOpenmrsObject(562) |2013-03-20 10:17:44,756| Unexpected exception occurred while saving openmrsobject: org.openmrs.Relationship, uuid '*********-********'

ERROR - SyncIngestServiceImpl.processSyncRecord(298) |2013-03-20 10:17:44,758| Unable to ingest a sync request

org.openmrs.module.sync.ingest.SyncIngestException: Could not save item for unknown reasons - not-null property references a null or transient value: org.openmrs.Relationship.personA

at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processOpenmrsObject(SyncIngestServiceImpl.java:563)

at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncItem(SyncIngestServiceImpl.java:423)

at sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)

......down the stack trace

Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: org.openmrs.Relationship.personA

at org.hibernate.engine.Nullability.checkNullability(Nullability.java:100)

at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:312)

......down the stack trace

ERROR - SyncUtilTransmission.processSyncTransmission(499) |2013-03-20 10:17:44,795| Sync error while ingesting records for server: [Server Name]

org.openmrs.module.sync.ingest.SyncIngestException: Could not save item for unknown reasons - not-null property references a null or transient value: org.openmrs.Relationship.personA

at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processOpenmrsObject(SyncIngestServiceImpl.java:563)

at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncItem(SyncIngestServiceImpl.java:423)

at sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)

...

CAUSE: Unknown...

SOLUTION: 

-Check to confirm that the person is missing on the receiving server

-Go on the server that sent the record and mark the failing record to be ignored ( use the “Remove as NOT SUPPOSED TO SYNC” link)

-On that server again , go to Manage Persons, search for the person and try to save the person again. This will cause a new sync record to be generated with the person data

-Confirm that this record syncs and go on the receiving server to see if the person has been created

-Go back to the sending server and set the failing record as a new sync record (by clicking the “Reset as NEW Sync Record” link)

-Confirm that the new record syncs, and Go to the receiving server to see if the record has been created

_____

BUG: Sync record fails to import because there is a missing PersonAttribute on a the current server.

DIAGNOSIS: Error message in logs on the server similar to the following:

ERROR - HibernateSyncDAO.processCollection(1273) |2013-03-25 09:27:29,935| Was not able to retrieve reference to the collection entry object by uuid.

ERROR - HibernateSyncDAO.processCollection(1274) |2013-03-25 09:27:29,936| Entry info: 

entryClassName: org.openmrs.PersonAttribute

entryUuid: 1813db65-a474-4af0-8132-b388ff13a9c0

entryAction: update

ERROR - HibernateSyncDAO.processCollection(1276) |2013-03-25 09:27:29,937| Sync record original uuid: 70358145-774b-4b91-b0c0-41615071552e|18792d72-7338-11e0-96bf-001e68a9fdcf

ERROR - SyncIngestServiceImpl.processSyncRecord(298) |2013-03-25 09:27:29,940| Unable to ingest a sync request

org.openmrs.module.sync.ingest.SyncIngestException: Could not find an object of type: org.openmrs.Patient missing org.openmrs.PersonAttribute with a uuid 1813db65-a474-4af0-8132-b388ff13a9c0

at org.openmrs.module.sync.api.db.hibernate.HibernateSyncDAO.processCollection(HibernateSyncDAO.java:1277)

at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncItem(SyncIngestServiceImpl.java:420)

....

CAUSE: The receiving server doesn't have the PersonAttribute specified in the sync record.

SOLUTION: I couldn't find a way to get a sync record with all the elements as the original one created, so I had to use manual sql to get the missing PersonAttribute created.

-Go first to the server that sent the record and check column values for the offending PersonAttribute. In my case, on the sending server I ran:

SELECT * FROM person_attribute where uuid="1813db65-a474-4af0-8132-b388ff13a9c0";

-Then use the values you get to run the insert statement on the server that is missing the record:

INSERT INTO person_attribute (person_id, value, person_attribute_type_id, creator, date_created, changed_by, date_changed, voided, voided_by, date_voided, void_reason, uuid ) SELECT (select person_id from person where uuid = "5cd067a6-5845-11df-b810-001e68a9fdcf"), 67, 7, 9324, '2012-10-15 11:05:46',10647, '2013-03-21 10:33:08',1, 9324, '2013-03-21 10:39:58', 'New value: 75', '1813db65-a474-4af0-8132-b388ff13a9c0' FROM person_attribute WHERE NOT EXISTS (SELECT * FROM person_attribute where uuid = "1813db65-a474-4af0-8132-b388ff13a9c0") LIMIT 1;

 

---------

BUGA sync record fails to import on a child server because when the parent server received the sync record (...from the original server where the record was created), it created the record but gave it a null payload.

DIAGNOSIS: Error message in logs on the server similar to the following:

ERROR - SyncIngestServiceImpl.processSyncRecord(306) |2013-05-16 10:27:18,546| Unexpected exception occurred when processing sync records
java.lang.NullPointerException
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncRecord(SyncIngestServiceImpl.java:198)
at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

...

ERROR - SyncUtilTransmission.processSyncTransmission(499) |2013-05-16 10:27:19,929| Sync error while ingesting records for server: Rwinkwavu
org.openmrs.module.sync.ingest.SyncIngestException: Unable to process sync record, processing terminated unexpectedly.
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncRecord(SyncIngestServiceImpl.java:310)
at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

...

Caused by: java.lang.NullPointerException
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncRecord(SyncIngestServiceImpl.java:198)
... 42 more

CAUSE:  Unknown...

SOLUTION: On the parent, identify the id of the failing record and update its payload using its value from the original server.

update sync_record set payload ='<items><SyncItem containedType="org.openmrs.DrugOrder" key="59365770-7a5d-4757-91c7-724f50b87303" state="UPDATED"><content><![CDATA[<org.openmrs.DrugOrder><startDate type="timestamp">2008-10-07T00:00:00.000+0200</startDate><complex type="boolean">false</complex><concept type="org.openmrs.Concept">3cd51772-26fe-102b-80cb-0017a47871b2</concept><instructions type="string"></instructions><orderType type="org.openmrs.OrderType">bcf7fb8e-2700-102b-80cb-0017a47871b2</orderType><discontinuedReason type="org.openmrs.Concept">3cdd5176-26fe-102b-80cb-0017a47871b2</discontinuedReason><frequency type="string">1/day x 7 days/week</frequency><units type="string">tab(s)</units><dose type="double">1.0</dose><creator type="org.openmrs.User">0d10b690-ce88-404d-9cd4-e82818b7351a</creator><patient type="org.openmrs.Patient">53d78221-1fc5-4972-9b3c-7b1e34f50dc5</patient><voided type="boolean">false</voided><prn type="boolean">false</prn><dateCreated type="timestamp">2011-07-07T18:34:43.000+0200</dateCreated><uuid type="string">59365770-7a5d-4757-91c7-724f50b87303</uuid><discontinued type="boolean">true</discontinued><discontinuedBy type="org.openmrs.User">0d10b690-ce88-404d-9cd4-e82818b7351a</discontinuedBy><drug type="org.openmrs.Drug">42f04f8c-26fe-102b-80cb-0017a47871b2</drug><discontinuedDate type="timestamp">2008-10-07T23:59:00.000+0200</discontinuedDate></org.openmrs.DrugOrder>]]></content></SyncItem></items>' where record_id="240689";

 

---------

BUG: Null pointer exception when importing a record containing an “ExtendedDrugOrder” object. (...from Order Extension Module).

DIAGNOSIS: Error message in logs on the server similar to the following:

ERROR - SyncUtilTransmission.processSyncTransmission(499) |2013-10-23 09:35:55,690| Sync error while ingesting records for server: Rwinkwavu
org.openmrs.module.sync.ingest.SyncIngestException: Unable to process sync record, processing terminated unexpectedly.
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncRecord(SyncIngestServiceImpl.java:310)
at sun.reflect.GeneratedMethodAccessor565.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

...

at org.openmrs.api.context.Daemon$2.run(Daemon.java:116)
Caused by: java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.openmrs.module.sync.api.impl.SyncIngestServiceImpl.processSyncRecord(SyncIngestServiceImpl.java:210)
... 42 more

CAUSE: For some reason, when the sync record was created, the "containedType" was not indicated in the sync record payload.

An example record looks like this:

SOLUTION: Add the missing "containedType" to the sync record payload and the record should now look like this:

Update then the payload of the record with sql command:

 

-------

 

BUGA sync record fails to import because the xml of the record got corrupted during the creation of the record

DIAGNOSIS: Error message in logs on the server similar to the following:



ERROR - SyncUtilTransmission.processSyncTransmission(499) |2014-05-06 06:41:33,605| Sync error while ingesting records for server: Kirehe
org.openmrs.module.sync.ingest.SyncIngestException: Transmission data was corrupted. Unable to process item.
at org.openmrs.module.sync.api.db.hibernate.HibernateSyncDAO.processCollection(HibernateSyncDAO.java:1195)

...

CAUSE: Unknown

An example record looks like this: (...check line #29 where the owner tag is '<owner type="recreate"></owner>')

 

SOLUTION: Fix the xml by adding the missing attributes and run an sql update to use this new payload.