New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replication of a new document causes multiple conflicts #3518
Comments
@episage it looks like you're creating conflicts with the SG bulk_docs API, and then you're surprised to get conflicts back from the SG changes API. If you don't want conficts back on the SG changes API, then why are you creating them? That's my interpretation on what I'm seeing based on:
Here it looks like you are creating two conflicting revisions (3-A, 3-B) for the If you can point to the code that is called from Also, taking a step back, if you could give a high level description of what you're trying to accomplish (and avoid), it might help in terms of recommending a best approach. Generally speaking, you want to avoid creating conflicting revisions in Sync Gateway, and so you'd never really want to purposefully insert conflicting revisions (if that's what you're actually doing). |
@tleyden The use case:
Here is a better example:
Here is the code of the adapter docsBulkWrite:
After the code executes, I expect the SGW to contain NO conflicts since the REVs are in-tact. HOWEVER, the database Extra: Here is the raw document in question (parent = -1): I would expect the document to have NO conflicts. Why does it happen? Is it an SGW error? |
NB, the documentation for SGW regarding replication is not-for-humans. Every time replication topic comes back, it makes me sick. |
What kind of app is this? I take it this isn't using a Couchbase Lite SDK? Is this a Phonegap-style app with "custom sync" to Sync Gateway?
Is Client A creating conflicting revisions with it's own changes, or changes from another client? |
From a high level design perspective, I would say that conflicts should only arise during concurrent offline updates to a doc by different devices:
at this point they will need to push conflicting revisions that are in conflict, since they diverged off of "doc1, rev1-a". OTOH, if the updates are on a single device, then you would always base changes on the previous revision, and you'd get a linear (non-conflicting) history of updates. Just want to focus on the high level usage before trying to drill in on the lower level potential API bugs. |
I think I see what's happening:
So it's creating three separate root revisions. In other words, your revision In the documentation for the
What might be happening this that you are sending Overall, it looks like you are recreating a lot of the functionality that Couchbase Lite provides rather than using Couchbase Lite, since maybe it doesn't suit your use case. If that's the case, you'll probably have to dig deeper into the Couchbase Lite code to see how it works (before it moved to the websocket based replication protocol, if you want to push over HTTP/REST). Another approach that might be easier to read the Couchbase Lite code is just to run the Todo sample app and sniff the replication using tools like:
That way you'll be able to see examples of the replication API usage. Closing the issue because I don't see enough evidence of this being a Sync Gateway bug. |
@episage one other thing that might interest you is the It returns a graphviz diagram of the revtree that can be visualized using graphviz (or webgraphviz.com if you don't want to install anything) Some examples of what the rendered revtrees look like (some with multiple-roots): #2847 (comment) |
@tleyden I'm writing SGW JS client (for browsers). |
Have you checked out PouchDB? You could probably leverage a lot of their existing work .. or at least use it as comparison for debugging (especially coupled w/ the network sniffing tools I posted). There has been few SGW tickets from people who are using PouchDB and ran into some minor compatibility issues. |
@tleyden I did many times and had many attempts at it but it's not compatible with SGW. It used to be a couple of years ago. |
and the |
Ok good to know |
@episage could you share a link to an example of that? It probably needs to be updated. |
@jamiltz AFAIK Couchbase/Sync Gateway don't have any documentation regarding writing a replicator. Thus, it's very difficult to write one. In terms of conflict resolution the only article that has some meaningful code and notes is this one:
|
@episage Thanks for the detailed feedback! Those are all valid points and noted https://issues.couchbase.com/browse/DOC-3575 |
Sync Gateway version
Operating system
Config file
default, nothing changed, look at
command
aboveLog output
Expected behavior
SGW should not return conflicts for
"rev": "2-A"
and"rev": "1-A"
when querying:http://localhost:5002/testing_1525080771752/_changes?active_only=true&style=all_docs
becasue each replicated document via post_bulk_docs has a unique revision and number
Actual behavior
SGW returns conflicts on
http://localhost:5002/testing_1525080771752/_changes?active_only=true&style=all_docs
.Every single document is conflicted (probably because each document's parent is equal to -1).
Steps to reproduce
The text was updated successfully, but these errors were encountered: