The Mobile app sync creates duplicates on the server if the connection fails or times out before the data syncs back to the device.
I am a bit rusty with mobile sync but I would have expected the server to roll back the db transactions in this case.
Is it a case of not having the correct exception handling in the correct place, or is there something else obvious I should have done to prevent this behaviour
A clearer discription of what is happening
1) The records are created on the device.
2) The sync is immediately triggered
3) The records are sent to the server and created successfully
4) The device loses connection (or times out) before the server records are able to be sent back to the device (I caused this to happen by debugging the sync and triggering airplane mode at the end of the server action flow)
5) The data is on the server but the data on the device still has the sync flags showing that it is on the device and needs to go to the server (isFromServer = false)
6) When a syncronisation is started again, the records are created on the server again, causing duplicates.
It occurs to me that just checking for duplicates on the server during the sync could be a solution, but I am concerned that if the server sync fails and doesnt create all of the required records and the joins between them, then data integrity may be lost.
Thanks! Any help is greatly appreciated. I will post the action flows below and try post an oml if it is needed.
Hi Mitchell,
Mobile sync should always consider that during sync the connection may be lost, so there must always be some method to recover from this situation. It very much depends on your situation (especially what type of data you have, and what the data model looks like) what is the best way to solve this. Some pointers: