Hello all,

In some obscure scenarios of lie-fi mixed / no-wifi, we have duplicated data sent from device to the server. 

This situation happens because offline sync is started two times at the same moment. When the first sync is running, the second sync gets the same data because the first one doesn't have time to update the local data.

Is there any way to block the execution of the second synchronization when the first one is still running?


Hi Duarte Oliveira,

As a simple suggestion, can you use a flag or date time stamp to control that issue?


Hi Duarte,

One thing to consider is to keep your sync events as short as possible. So maybe multiple small sync rather than one with a lot of data to sync. An additional benefit of this approach is that you will experience less situations where the sync is aborted and retried do to the connection not being available.

In either case, it makes sense to only start the next sync if the first finished. So you could create a local storage entity and keep track of the last sync (you probably have already), and put an extra attribute in type boolean that you set to true if sync starts and to false if it ends succesfull or with error.

That way you can control the start of a sync by checking that attribute.



In scenarios where connectivity is bad, it's not unusual for a process to be interrupted and restarted. While you can add a flag to make sure the same device doesn't start two concurrent syncs, your server logic should be prepared to handle that without creating duplicate records; ideally your mobile-created records should have a combination of values that make them unique and that the server can use to validate if it has already created.

Thanks for the answer.

The semaphore strategy is not an option because it's possible a second sync to be started before the first one has time to store the timestamp.