fix: Run sync request synchronously [DHIS2-21606][2.42]#24291
Conversation
|
enricocolasante
left a comment
There was a problem hiding this comment.
I am confused by the overlapping of this PR and the other one already opened.
Only single events is going to be sync?
The delete an already deleted single events wasn't an issue before right? Because an already deleted event would have been already synchronized and it should be present in the paylaod at all. The already deleted issue is only an issue for entities without the synchronized field (enrollments and from now on tracker events)
I mentioned in the description that I'll also make the tracker data sync job synchronous.
I'm not sure what you mean by this. I applied the fix here as well for consistency with the other import validations. Also, if the remote instance soft deletes an event and it is then synchronized to the local instance, the import fails with the same error. If the local instance already has that event soft deleted, I think it makes more sense to report it as a warning instead of an error. |



When syncing single events to a remote instance, two issues could cause unnecessary failures:
Already deleted events: If the target had already processed an event deletion, importing the same deletion again raised error
E1082, causing the sync to fail. This error is now downgraded to a warning forDELETEimports. Additionally,PersistablesFilterskips persisting entities that are already marked as deleted in the preheat, avoiding redundant write attempts.Run the request synchronously: The sync request was executed asynchronously, but its status was never polled. Instead, it was always assumed to have succeeded. As a result, single events could be marked as synchronized even if the import had failed, leaving the source and target instances out of sync without detection. The request is now executed synchronously (matching the platform behavior), and single events are marked as synchronized only if the remote import completes successfully.
The overload of
SyncUtils.runSyncRequestis added to accept a caller-suppliedResponseExtractor<T>. The existing overload only handledImportSummary/ImportSummaries(the old DXF2 format), but the tracker endpoint returnsImportReport, making it incompatible. The new overload preserves the retry-on-5xx behavior while letting callers deserialize the response into any type. It will be reused in a follow up PR that applies the same fix toTrackerDataSynchronizationService.