Integrity check incorrect field indexes

Hi,

I’m running Codebook 4.5.20.0. I sync via Google Drive between Windows and iOS devices. I periodically perform an integrity check. Today I noticed an issue propagating some new and changed fields. Here are the steps to reproduce:

device #1
File > Integrity Check, No Problems
Sync > Sync with Google Drive
File > Integrity Check, <#> incorrect field indexes fixed
Sync > Sync with Google Drive
File > Integrity Check, No Problems

device #2
File > Integrity Check, No Problems
Sync > Sync with Google Drive
File > Integrity Check, <#> incorrect field indexes fixed
Sync > Sync with Google Drive
File > Integrity Check, No Problems

start over at device #1, ad nauseam, without any additional database changes.

Any idea what’s going on?

codebook_integrity_check_issue

@jhmpub

Thanks for using Codebook and posting to the discussion forum with this question.

The situation you outlined could occur if you edited/added/removed fields on the same Entry on two different devices and then synced.

Here’s a simplified example which can cause this:

Imagine you have an Entry which was already synced on both devices and is fully up to date. It was 3 fields:

Index 1: Username
Index 2: Password
Index 3: Website

One device 1, you add a new Field at the end of the list Note, so the Entry on device 1 looks like this:

Index 1: Username
Index 2: Password
Index 3: Website
Index 4: Note

Without syncing device 1 + device 2 first, on device 2, you add a Note field at the end of the same entry. The entry on device 2 now looks like this:

Index 1: Username
Index 2: Password
Index 3: Website
Index 4: Note

Now you sync device 1, then device 2, then device 1 again to Google Drive. The result is that both devices will have the same data on both side, but the indexes of the newly added Note fields on each side will both be Index 4. So it might look something like this prior to Integrity Check:

Index 1: Username
Index 2: Password
Index 3: Website
Index 4: Note << added by device 1
Index 4: Note << added by device 2

When running Integrity Check, it recognizes that there are incorrect field indexes on this Entry and fixes them up so that they are correctly ascending.

A similar issue could occur if you deleted a field on one device, and prior to syncing it, added/moved other fields around on the same Entry on the other device.

Does this sound similar to the steps you could have taken when this issue occurred?

Typically to avoid this issue, we’d recommend trying to edit an Entry on one device at a time.

This issue should be a lot less likely to occur in Codebook 5 when using Codebook Cloud: Codebook Cloud - Beta Testers Wanted!

What you explain is what I would expect with database change collisions.

My problem is I repeatedly get incorrect field indexes fixed after a sync on device 1 and then a sync on device 2 with no database changes.

@jhmpub

Thanks for the response with the further details.

This does sound like it could be a bug. We’ll work on trying to reproduce it on our end.

One follow up question to help us try to narrow down the reproduction case: if you sync your two devices with no pending changes at all, does it also reproduce the issue? i.e. these steps:

  1. Device 1, and Device 2 fully in sync with Google Drive and each other (and Integrity Checks passing).
  2. Device 1, sync with Google Drive, Integrity Check << does this produce any Integrity issues?
  3. Device 2, sync with Google Drive, Integrity Check << does this produce any Integrity issues?
  4. Device 1, sync with Google Drive again, Integrity Check << does this produce any Integrity issues?

Thanks!

1. Device 1, and Device 2 fully in sync with Google Drive and each other (and Integrity Checks passing).
check
2. Device 1, sync with Google Drive, Integrity Check << does this produce any Integrity issues?
intermittently, roughly every other time, always 7 incorrect field indexes fixed
3. Device 2, sync with Google Drive, Integrity Check << does this produce any Integrity issues?
intermittently, roughly every other time, always 7 incorrect field indexes fixed
4. Device 1, sync with Google Drive again, Integrity Check << does this produce any Integrity issues?
again, intermittently, roughly every other time, always 7 incorrect field indexes fixed

Hope that helps