Syncing Inconsistent Data

Discussion of the iOS App Dive Log
Post Reply
cpraneri
Posts: 9
Joined: Mon May 25, 2020 5:23 pm

Syncing Inconsistent Data

Post by cpraneri » Fri May 29, 2020 6:38 am

Hi Greg, I keep DiveLog on both iphone and ipad. What will happen if I make changes to any data, e.g. dive time, and do this on both devices independent of each other, meaning the entries are different times. How does DiveLog handle inconsistent data when user chooses the “Matching Logbook Avail for Sync” function (this is all under the IOS sync choice, of course)?

support
Posts: 705
Joined: Wed Mar 31, 2010 4:35 pm

Re: Syncing Inconsistent Data

Post by support » Fri May 29, 2020 9:29 am

Hi,

Dive Log maintains internal records that allow it to automatically merge two (or more) logbooks that are updated independently on two (or more) devices. The logbooks need to have started out life from the same base logbook (otherwise you will not see it in the "matching Logbooks Available for Sync." section of the iOS iCloud Synchronization) so that the internal records are relevant during the sync process. Dive Log manages it's sync on a record by record basis (for example a "dive", "dive site", "city", "country", "trip", "marine life", "equipment", etc.). You can make a change to any record on one device and if that change was the most recent one for that record, then that complete record will "win" and be the resulting record during a sync. The best idea is to only make changes to any particular record on one device at a time between syncs ... but you can change any independent records that you like on either platform.

For example, if you have a Dive #2 and a Dive #5 and you make a change to Dive #2 on your iPad and a change to Dive #5 on your iPhone and then sync both dives will be updated appropriately in the final result. However, if you change say the water temp for Dive #2 on your iPad and then a few minutes later the air temp for the same dive (Dive #2) on your iPhone and then sync, the complete dive record as it was on the iPhone will be the final result (so the air temp will be changed but the water temp will not reflect the change from the iPad).

The internal record keeping means that you can change any user editable value in a "record" as we don't use any of the user visible data to identify a record. For example, you can change the dive number or dive date of a dive and the sync process will appropriately update that during the sync without conflict. Further, any dependent records (for example a dive site or a marine life item assigned to a dive) will be correctly managed during a sync. Finally, we keep track of deleted items. So if you delete an item on one device and it previously existed on the other device, then it will also be deleted from the final result (this way you don't have records coming back to life as the result of a sync).

Keep in mind that if you add a record on each device then both records will be in the final result. So you can't create a dive site on one device and then create the same dive site on the second device and expect them to be the same dive site. The sync process will create two records (with different internal accounting information) that may have the same name. So if you need to create a dive site, create it on one device and then sync with the other to pick up the same record.

iCloud presents some interesting challenges as it is possible to "sync" while you are offline (or Apple's servers are offline) and there is no guarantee that the device will get connected and the logbook uploaded to the "cloud" before another device (or even the same device) syncs again. Dive Log can manage these conflict versions and will process through all the conflict logbooks that it finds on each sync and make sure that the most recent changes from all the logbooks are in the final result.

The "time stamp" that is associated with a record is based on the date/time of the device (normalized to a standardized international time) that the device had at the time the record was updated, created or deleted. Fortunately, iOS devices have clocks that are generally accurate and consistent across devices (the time zone does not matter, just the absolute time) due to the way they update their internal clocks. So it is usually the case that we can account for changes to a given record to a resolution that is much finer than your ability to actually make the changes. In theory, if you manually set the clock of your iOS device to the wrong time (again time zone is not important) this could mess up the sync order, but in practice this is not an issue.

That is probably way more detail than you were looking for, but do let me know if I failed to address your question or if you need any additional information.

Cheers,

Greg

cpraneri
Posts: 9
Joined: Mon May 25, 2020 5:23 pm

Re: Syncing Inconsistent Data

Post by cpraneri » Sat May 30, 2020 7:09 am

Thank you Greg!

cpraneri
Posts: 9
Joined: Mon May 25, 2020 5:23 pm

Re: Syncing Inconsistent Data

Post by cpraneri » Wed Jul 08, 2020 4:55 am

Greg, A quick follow up. Want to make sure I’m clear on something. When in the iCloud Syncronization menu I use the import feature when I want to 100% overwrite a log on one device from another. But we use the “Matching Logbooks Avail for Sync...” feature when we simply want to bring in changes from another device, like an added dive, or a changed data field on an existing dive. Both pathways are equally as robust but there is no reason to do a full “import” for each change however minor from one device to another. Once set up (meaning the same divelog on my iPhone and iPad) I am simply adding dives or changing data fields and the “Matching Logbooks Available for Sync....” is the appropriate choice. Is this a good summary? I realize we need to be careful about editing the same field in the same dive on each device - the most recent will take precedence, and there the younger change will be lost.

support
Posts: 705
Joined: Wed Mar 31, 2010 4:35 pm

Re: Syncing Inconsistent Data

Post by support » Wed Jul 08, 2020 8:10 am

Yes, that is an excellent summary.

The one other thing that the "matching logbooks" option does is upload the sync'ed logbook back up to iCloud. This way if you have any local changes to the device you are executing the sync on they will be uploaded to iCloud as part often operation (making them available to sync onto another device).

In general, the "matching logbooks" option is usually your best choice unless you are trying to recover a logbook (or deal with some other sort of issue) as this will ensure that you have any local changes backed up to iCloud and that you don't inadvertently overwrite any local changes. However, you've got the concepts down, so you can use the features as they best suit your situation.

Cheers,

Greg

Post Reply