"not_found" error trying to delete a CBLDocument on iOS 11.3 (CBL 1.4.1)

4 views
Skip to first unread message

Brendan Duddridge

unread,
Apr 4, 2018, 3:00:15 AM4/4/18
to Couchbase Mobile
Hi,

I have a situation in a customer's database where he has a basically empty record that can't be deleted.

I traced through the code and found that CBL (1.4.1) is returning kCBLStatusNotFound when trying to delete (or even modify) the document.

Here's the relevant code being executed in CBL_SQLiteStorage.m (1728) in 

- (CBL_Revision*) addDocID: (NSString*)inDocID

                 prevRevID: (CBL_RevID*)inPrevRevID

                properties: (NSMutableDictionary*)properties

                  deleting: (BOOL)deleting

             allowConflict: (BOOL)allowConflict

           validationBlock: (CBL_StorageValidationBlock)validationBlock

                    status: (CBLStatus*)outStatus

                     error: (NSError**)outError


....


        SequenceNumber parentSequence = 0;

        if (prevRevID) {

            // Replacing: make sure given prevRevID is current & find its sequence number:

            if (isNewDoc)

                return kCBLStatusNotFound;

            parentSequence = [self getSequenceOfDocument: docNumericID revision: prevRevID

                                             onlyCurrent: !allowConflict];

            if (parentSequence == 0) {

                // Not found: kCBLStatusNotFound or a kCBLStatusConflict, depending on whether there is any current revision

                if (!allowConflict && [self existsDocumentWithID: docID revisionID: nil])

                    return kCBLStatusConflict;

                else

                    return kCBLStatusNotFound;

            }



In bold red is the line that's being executed.

Is there any way that I can get rid of this document even though the parentSequence is 0 and it falls through to the else statement? I just want to be able to delete it and move on. But it's preventing any documents in a batch transactions from being saved if this document appears in the transaction block being saved.


Thanks,

Brendan

Brendan Duddridge

unread,
Apr 4, 2018, 3:03:49 AM4/4/18
to Couchbase Mobile
Also, I ran the Compact Database function on the database hoping that a good vacuum and compaction would resolve the problem.

But it didn't help.

Thanks,

Brendan

Jens Alfke

unread,
Apr 4, 2018, 2:10:18 PM4/4/18
to mobile-c...@googlegroups.com


On Apr 4, 2018, at 12:00 AM, Brendan Duddridge <bren...@gmail.com> wrote:

Is there any way that I can get rid of this document even though the parentSequence is 0 and it falls through to the else statement?

This looks like a bug — we should continue the discussion on Github Issues.

-getSequenceOfDocument: should not be returning 0 if the doc actually exists. So something must be wrong.

—Jens

Brendan Duddridge

unread,
Apr 4, 2018, 3:30:06 PM4/4/18
to Couchbase Mobile
Ok, I'll create a GitHub issue for it. 

Thanks,

Brendan
Reply all
Reply to author
Forward
0 new messages