Lost server and attachments?

I am wondering if CouchBase system would survive a server data loss if we have attachments stored on mobile devices?

Lets say we have 2 iPhones with CBLite and each push 100 documents with attachments to server. And these documents have many changes so that attachments’ revpos do vary. Some have also changes where only JSON was changed but not the attachments. On this scenario, server is lost and started from scratch without any data. CBLite replication would start replication from the begining again - but is everything needed there to replicate back all these attachments too?

I am afraid that CouchDB style replication would need every document rev pushed separately, because attachments’ revpos relate to certain _rev:s. Revpos cannot refer to non-existeng version I guess? So replicating only the current, newest state from iPhones to server would not work?

(Interesting question is also that could CouchDB replication protocol allow referring to non-existing revision in revpos?)

This topic relates to our current use case. Would be nice to hear if someone has insight if this is supposed to “just work” or do we have to take some precautions while designing this. One “safer” solution could be to have separate documents for attachments…

Yes, the attachments will replicate fine just like the documents. It’s just like replicating to a new client.

The revpos just indicates how recently the attachment was changed; it’s an optimization for the replicator so it doesn’t have to push an attachment again if it didn’t change.

OK, very good it works this way, thanks!

One more question about this: lets say 2 iPhones have exactly same attachment (digests match). Will both of them upload the same attachments to server in this failure scenario? Or is there something to ensure no extra upload will happen even if server data was lost?

As part of the upload process the replication algorithm will ask the remote endpoint which revisions it already has, and if it already has the one with the attachment then it will not attempt to send it.

True, that takes care of not uploading many times. Thank you!