We think the cause of this issue was that our sync gateway server went down for a few hours, and users that are active during that time frame are now having issues syncing their data. We are seeing this error in the sync gateway logs for them:
400 Missing digest in stub attachment “profileImage” (400 Missing digest in stub attachment “profileImage”)
Is there any way for us to fix the document that the problem image is attached to from the server side? We don’t want the users losing all their data for the past couple of weeks, so if there is a way for us to just fix the one document and get it pushed to their phones so that they can sync again that would be perfect.
Have you tried pushing a revision of the document without the attachment, then adding the attachment back in a subsequent revision? If it’s actually similar to #1034, I think this would trigger generation of a new digest for the attachment.
Sorry for taking so long to get back, we finally got around to tackling this issue in depth and found that deleting the attachment on the server doesn’t work. We are starting to get this error for a lot of users. We are investigating this further but our current workaround is to have users go to a page in our application that restarts the replicators, this will cause the data to sync, but then it will stop because it gets the 400. So they can sync data, but it isn’t continuous. We then ask them to log out of our application and log back in after they sync so that their db is cleaned.
So currently it seems like you should just not use attachments at all if you use sync gateway, they are too unstable and dangerous.
I’d like to get to the bottom of this, and in particular confirm whether it’s the same issue as 1034. If you have any client or Sync Gateway logs that you can share when users hit this issue, I’d appreciate if you could add them to https://github.com/couchbase/sync_gateway/issues/1034 (preferably as a link to a gist). Once we’re able to reproduce the issue internally we can investigate how to recover from the issue when it happens in the current release, as well as getting it fixed in an upcoming release.
The short explanation is that the server and client get out of sync because the client is offline for a while. The document that has an attachment connected to it is updated on both of them, and by the time the client comes back online and tries to sync the original revision that the attachment was connected to has been compacted and deleted. Sync gateway then fails to sync the document because it can’t find the parent document of the attachment and the document never syncs again until you delete the local DB and do a full resync.
It is pretty common for us because the document we have attachments attached to is updated fairly often, and our clients are often offline for long periods of time.
NOTE: We were mistaken about this causing our general sync issue. This ONLY affects the document with the attachment. Other data syncs fine. Our general issue with no data syncing has no known cause yet, but we often have issues with syncing so it is probably just a new syncing issue. We’re trying to log more information about syncing issues but it’s really hard to do with couchbase lite because it keeps all that stuff internal.