Should _deleted be used only as an end-of-a-branch marker?

46 views
Skip to first unread message

Pavel Malyshev

unread,
May 9, 2014, 11:17:47 AM5/9/14
to mobile-c...@googlegroups.com
Hi, i'm using Couchbase Lite Android, and i'm not sure what is the best way to delete documents.

One approach is to simply put a _deleted property into the document, but i'm afraid it will cause problems with conflict detection. For example:
1. Device A and device B both have revision 1-foo.
2. User on device A updates the document and produces 2-bar.
3. User on device B deletes the document and causes  _deleted property to be set in the document, producing 2-baz.
4. Device A replicates to device B, so now it has 2-bar and 2-baz. 
CBLite won't say it's a conflict( if i'm right about getConflictingRevisions() ), but from the user's point of view it is a conflict.
And if we'll try to find all leaf revisions( with getLeafRevisions() ), we won't be able to distinguish solved conflicts from unsolved conflicts.

Also, i hoped that if i'll add a "_deleted: true" into the document instead of calling delete() (Like "Deleting documents with Filtered Replications" section of guide says) CBLite will retain document contents, but it seems it won't.
I've tested that with curl PUT and subsequent curl GET and got only _id, _rev, and _deleted.

So should i use my own property ( i.e. "deleted" without underscore ) to mark revisions which were deleted by user, and use _deleted only to mark revisions which were deleted during conflict resolution?

Traun Leyden

unread,
May 9, 2014, 2:13:45 PM5/9/14
to mobile-c...@googlegroups.com

testRemoteConflictResolution() introduces a conflict by adding a "_deleted" property.  It also has an assertion that calls getConflictingRevisions().

Can you try to modify testRemoteConflictResolution(), or add an entirely new test, to reproduce the issue you are seeing?  If you can reproduce, please file a github issue.


--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/c4f86959-11cc-4f0e-80fb-490cc1d8d2c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pavel Malyshev

unread,
May 9, 2014, 4:23:45 PM5/9/14
to mobile-c...@googlegroups.com
My post isn't about a bug, i'm sorry if it looks so.  I'm new to CBLite and just asked if i understand something wrong.


On Saturday, May 10, 2014 1:13:45 AM UTC+7, Traun Leyden wrote:

testRemoteConflictResolution() introduces a conflict by adding a "_deleted" property.  It also has an assertion that calls getConflictingRevisions().

 Adding revision with a "_deleted" property in this test actually resolves conflict, right?

Jens Alfke

unread,
May 9, 2014, 5:08:17 PM5/9/14
to mobile-c...@googlegroups.com

On May 9, 2014, at 1:23 PM, Pavel Malyshev <pamal...@gmail.com> wrote:

My post isn't about a bug, i'm sorry if it looks so. 

But you did describe a behavior that definitely is a bug if it’s reproducible:

Also, i hoped that if i'll add a "_deleted: true" into the document instead of calling delete() (Like "Deleting documents with Filtered Replications" section of guide says) CBLite will retain document contents, but it seems it won't.
I've tested that with curl PUT and subsequent curl GET and got only _id, _rev, and _deleted.

—Jens

Pavel Malyshev

unread,
May 10, 2014, 1:32:40 PM5/10/14
to mobile-c...@googlegroups.com
I've posted an issue.
Reply all
Reply to author
Forward
0 new messages