Sub-Document Mutate operations not working properly with XDCR

We have setup 2 couchbase clusters with XDCR between them. We are using sub-doc mutate to update document with new fields (there is no removal of any field, also no field is being overridden/updated).
We found out that if we are updating same document concurrently via cluster 1 and cluster 2, some updates are getting lost.
for eg: if we add field-1 in document-1 via cluster-1 and concurrently field-2 is being added to document-1 from cluster-2, then only one update will be effective and either field-1 or field-2 would be missing from the resulting document.
Is there any way we can solve this issue so that there is no data loss? Our original thought was that because this was a “sub-doc” operation, XDCR would take this into consideration and merge both document versions by updating final document accordingly based on individual paths provided during sub-doc mutate operations.

For anyone else following this issue, here’s a link to the StackOverflow post where Matthew Groves explains what’s happening:

1 Like