Getting error loading parent revision's properties

7 views
Skip to first unread message

Brendan Duddridge

unread,
Oct 23, 2017, 4:05:15 AM10/23/17
to Couchbase Mobile
Hi,

When I attempt to get a CBLRevision's parent revision properties, I'm getting the following error:

01:58:52.774 WARNING: Couldn't load body/sequence of CBLSavedRevision[itm-..ee61/1-3cba2f866ae42de425f82828079eaf31]: 404 {at -[CBLSavedRevision loadProperties]:215}


I'm trying to restore a deleted document and so I get the leaf revisions, get the first object in the results, and if it has only deletion information, I ask for the revision's parent and then get the parent's properties. But that's throwing the above error for many of the documents.

This is what the first leaf revision looks like:

(lldb) po revision.properties

{

    "_deleted" = 1;

    "_id" = "itm-116785a587234b30a62401acd26e00b0";

    "_rev" = "2-ef6861107f684520f83202d1cdd9b3c5";

}


And when I see that "_deleted" = 1, then I ask for the parent revision and get it's properties. But in many cases I just get that warning error.

Here's the code that's causing the error:

NSArray *leafRevisions = [row.document getLeafRevisions:&error];

 

CBLSavedRevision *revision = [leafRevisions firstObject];

 

if (revision && !error) {

 CBLJSONDict *properties = revision.properties;

 if ([(NSNumber *)properties[@"_deleted"] isEqual:@1]) {

revision = revision.parentRevision;

properties = revision.properties;

 }


Am I doing the right thing here to get the most recent revision that is possible to recover?

Thanks,

Brendan

Jens Alfke

unread,
Oct 24, 2017, 12:47:52 PM10/24/17
to mobile-c...@googlegroups.com


On Oct 23, 2017, at 1:05 AM, Brendan Duddridge <bren...@gmail.com> wrote:

I'm trying to restore a deleted document and so I get the leaf revisions, get the first object in the results, and if it has only deletion information, I ask for the revision's parent and then get the parent's properties. But that's throwing the above error for many of the documents.

Looks like the parent revision’s body has been compacted away. CBL doesn’t guarantee to keep past revisions around; it’s not a version-control system. If you’re using SQLite storage they should stick around until you manually compact, though.

—Jens

Brendan Duddridge

unread,
Oct 24, 2017, 11:30:45 PM10/24/17
to Couchbase Mobile
Looks like the parent revision’s body has been compacted away. CBL doesn’t guarantee to keep past revisions around; it’s not a version-control system. If you’re using SQLite storage they should stick around until you manually compact, though.

Is there a way to preempt this error? I feel like it's slowing down fetching of my deleted documents. From my previous email, it took 590 seconds (9.8 minutes) to loop through 88380 deleted documents to try and get the ones that have data in them that can be restored.

Perhaps by using CBLRevision's propertiesAvailable method?  Yes, I'm using SQLite so the objects are hanging around until manually compacted, which is exactly what I want. I'm not trying to make it a version control system, just an easy way to restore recently deleted objects. Like making a trashcan function.

Thanks,

Brendan

Reply all
Reply to author
Forward
0 new messages