Documents never synced to server owing to error

Hi

I’m seeing two errors in the Android log that seem to be preventing my device’s database from fully syncing with server. This means that whenever I start replication, I see a ton of activity where it’s trying to sync, but never manages to resolve the errors, leading to high network usage (I don’t particularly want to disable replication on mobile networks).

The errors fall into two classes. The first is a problem with attachments, and the error is very similar to one I saw in the forums that was apparently fixed in Sync Gateway 1.2 (which we’re using). A typical log entry is:

09-15 13:24:36.705 12570-10166/com.totl.eventtracker W/Sync: {error=bad_request, id=9f704700-50ca-4e8e-888f-d12ba34ef7be, reason=Missing digest in stub attachment “thumbnail”, status=400}: _bulk_docs got an error: com.couchbase.lite.replicator.PusherInternal$4@3b8b890

The other error is a MIME type one and looks like this:

09-15 13:24:45.375 12570-10236/com.totl.eventtracker W/Sync: {error=bad_content_type, id=da6b589d-6bf2-40d3-a932-ef786d980ebc, reason=Invalid content type text/plain, status=415}: _bulk_docs got an error: com.couchbase.lite.replicator.PusherInternal$4@17ee567

There are MANY examples of this in the DB.

The Couchbase Lite DB was built under version 1.2.1, but I’ve upgraded to 1.3.0 now, with no change to problems mentioned above.

A general question leading from this issues is: is there any way to effectively clear the sync jobs for cases that seem to be unrecoverable? And how would I even know that the problem exists, outside of what I see in the log?

Thanks!

Fyi this looks like this issue. Have you deleted and recreated the attachments in question?

As for the other questions what does the lastError property of the replication show?

What server are you replicating with?

Hi, no, once the attachment is created, it’s never touched. The code in question is:

                    final InputStream is = pipe.getInputStream();

                    final Document doc = mDao.getExistingDocument(event.getId());
                    final UnsavedRevision rev = doc.createRevision();
                    rev.setAttachment(Constants.Couchbase.EVENT_ATTACHMENT_NAME_THUMBNAIL,
                            "image/jpeg", is);
                    try {
                        rev.save();
                    } catch (final CouchbaseLiteException e) {
                        mLog.e(TAG, "Couldn't save thumbnail attachment", e);
                    }

I don’t see any errors. I added this to my replicators:

final Replication.ChangeListener changeListener = new Replication.ChangeListener() {
    @Override
    public void changed(final Replication.ChangeEvent event) {
        final Replication source = event.getSource();
        final String type = source.isPull() ? "Pull" : "Push";
        mLog.d(TAG, type + " lastError ", source.getLastError());
        mLog.d(TAG, type + " eventError ", event.getError());
    }
};
mPush.addChangeListener(changeListener);
mPull.addChangeListener(changeListener);

and when I filter the log for “Error” all I see is, e.g:

09-16 09:25:47.976 25101-25288/com.totl.eventtracker D/DbMgr: Push lastError 
09-16 09:25:47.979 25101-25288/com.totl.eventtracker D/DbMgr: Push eventError 
09-16 09:25:47.989 25101-25288/com.totl.eventtracker D/Sync: retryReplicationIfError() state=IDLE, error=null, isContinuous()=true, isTransientError()=false
09-16 09:25:47.990 25101-25288/com.totl.eventtracker D/DbMgr: Push lastError 
09-16 09:25:47.991 25101-25288/com.totl.eventtracker D/DbMgr: Push eventError 
09-16 09:25:48.709 25101-25288/com.totl.eventtracker D/DbMgr: Pull lastError 

09-16 09:25:48.715 25101-25288/com.totl.eventtracker D/DbMgr: Pull eventError

Cheers,
Pete

Hey Jens, we’re using:

Version: 4.5.0-2601 Enterprise Edition (build-2601)

Cheers,
Pete

@jens @borrrden Any more thoughts based on my responses?

I think he meant what version of Sync Gateway, not Couchbase Server.

Oh, as I mentioned in my first post, we’re using Sync Gateway 1.2, with some minor modifications.

Sorry, I don’t work on the Android implementation; @hideki would be the best person to look into this.