I have been running into issues with the old attachments created with CBL 1.x which I detailed here:
Now I observe that SG does not push down attachments, too. Here’s the SG log:
[INF] SyncMsg: c:[1f6b1d87] #4: Type:getAttachment Digest:sha1-GL8jR+MlmM4+wqqKe3372FkLL70=
[INF] SyncMsg: c:[1f6b1d87] #4: Type:getAttachment --> 403 Attachment's doc not being synced Time:13.39µs
...
[INF] SyncMsg: c:[1f6b1d87] #3: Type:getAttachment Digest:sha1-8IE/kBltWJR4lUs7ynBdj0G9+Pw=
[INF] SyncMsg: c:[1f6b1d87] #3: Type:getAttachment --> 403 Attachment's doc not being synced Time:6.867µs
I also saved the SG debug log but it’s over 5k lines.
On the Android client I see this:
E/CouchbaseLite/REPLICATOR: {N8litecore4repl12IncomingBlobE#3}==> N8litecore4repl12IncomingBlobE for doc 'Qh9zvlESWUeJKbRw3LukBfCu7LV2::userProfile'._attachments["Qh9zvlESWUeJKbRw3LukBfCu7LV2::large"] [sha1-8IE/kBltWJR4lUs7ynBdj0G9+Pw=] @0x6f4961b0c8
E/CouchbaseLite/REPLICATOR: {N8litecore4repl12IncomingBlobE#3} Got error response: HTTP 403 'Attachment's doc not being synced'
E/CouchbaseLite/REPLICATOR: {N8litecore4repl12IncomingBlobE#3} Got error response: HTTP 403 'Attachment's doc not being synced'
To solve the issue via code I tried:
resetting the checkpoint and one-shot pull it
adding a field to the document via web request and Java SDK. The update should make the SG push it down to the client
creating the document on the client … it wasn’t updated on the server. Likely because the revision on the client starts with 1… while the one on the server has likely a higher revision number and thus it’s rejected. Or because of another reason it is rejected. That’s a guess on my part
In testing it helped to delete the attachment part of the document in the document viewer in the browser of Couchbase Server. It’s not confirmed by the affected user in production yet. As of now this is a manual effort. I might have to do this with all documents of all users who run into this issue. Additionally their attachements are gone.
This is the same bug as you’ve found when pulling documents (CBG-741). We’re working on a fix for this, but in the meantime, I’ve advised that documents affected by this bug can be fixed by writing a new revision through Sync Gateway.
The following curl command retrieves the active revision of a given document, and writes it back to Sync Gateway, creating a new revision with the same data:
Comparing two documents, one that was fixed with the command and one with blobs show differences though:
The fixed document has no attachment/blob field in the json. It has this in the meta data:
Q1) With these observed differences is it still safe to use this command on all “broken” documents?
Q2) I was planning to update all old documents with attachments: delete the attachments and add them as blobs on the client. Is it planned to provide a SG command to do this for the whole database?
I compared it with another document which also has only old attachments. It looks the same. So it’s safe to use the command. I cannot remember if before SG 2.x the attachments were also (or only) in the json body.