Peer to peer sync losing data issue on iOS

13 views
Skip to first unread message

Brendan Duddridge

unread,
Sep 14, 2016, 2:17:55 PM9/14/16
to Couchbase Mobile
Hi,

I have some customers who have told me that when using Nearby sync they're losing some data after the sync.

Here's what's happening.

1. Two or more devices are configured to sync with each other using peer-to-peer sync.
2. One device has more records than the other.
3. When they bring the other device(s) online, the device with more records has those extra records deleted rather than the device coming online receiving the extra records from the first device that had more records.

So I'm wondering what could be causing this kind of issue and how I would go about preventing it from happening?

I would assume that the device that had more records would have a later sequence number than the other devices and therefore the extra data would be sent to the other devices. But it seems sometimes the device with fewer records is taking precedence.

Any help or ideas would be greatly appreciated.

FYI, in my setup, each device starts out with a copy of the same database file before sync is initiated. That is, the user physically copies the database file from one device to the other, then sync is setup between them. Upon the first time that database is opened, my app will issue a call to [couchDatabase replaceUUIDs:] if it detects that the device that created the database is different than the device that's now opening the database. It does this only one time. I mention it here because I thought it might be relevant to the issue at hand.

Thanks,

Brendan

Jens Alfke

unread,
Sep 14, 2016, 2:48:03 PM9/14/16
to mobile-c...@googlegroups.com

On Sep 14, 2016, at 11:17 AM, Brendan Duddridge <bren...@gmail.com> wrote:

3. When they bring the other device(s) online, the device with more records has those extra records deleted rather than the device coming online receiving the extra records from the first device that had more records.

The only way a document can be deleted by a replication is if the other peer has a deleted revision (tombstone) of that same document, which is a direct descendant (i.e. not a conflict) of the first peer’s revision. The replicator would never delete a document just because it didn’t exist on the other side; that’s not how it works.

Is there a way you can get a copy of a database that’s had this happen?

—Jens

Brendan Duddridge

unread,
Sep 14, 2016, 2:51:32 PM9/14/16
to Couchbase Mobile
That's what I figured, but that's not what seems to be happening. The other device doesn't have the data on it yet.

I'll see if I can get a copy of the database this happened on.
Reply all
Reply to author
Forward
0 new messages