Skip to content
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

Deleted conflicts do not propagate between nodes #113

Open
nicozimmermann94 opened this issue Feb 19, 2016 · 5 comments
Open

Deleted conflicts do not propagate between nodes #113

nicozimmermann94 opened this issue Feb 19, 2016 · 5 comments

Comments

@nicozimmermann94
Copy link

TL;DR: How do I tell ember-pouch to delete the entire doc (not just the rev) with model.destroyRecord?

I have a simple setup with a list of friends with names. I create a new friend Mike on Client A. It gets synced to Client B. Now I change the name of the friend to Peter on Client B while being offline and parallel I change the name to Arnold on Client A while being online. When Client B gets online again, we have a conflict, it makes sense. A winner will be selected, so far so good.
Now I want to delete this friend. But what happens? The friend does not disappear. The friend will get the name of the "loser" leaf instead. I read that this is intended.
But how do I tell ember/ember-pouch/pouch to delete the entire doc when I click destroyRecord within ember?

@nolanlawson
Copy link
Member

It is indeed intended that deletions propagate throughout the network. AFAIK, shouldn't ember-pouch update the Ember store when it receives changes from a remote database that delete a record? If not, it does indeed sound like a bug.

I.e. these lines of code are supposed to do what you're asking, assuming that it actually works as intended.

@nicozimmermann94
Copy link
Author

I do not quite understand what happens. When I create such a conflict where 2 Clients change the doc parallel/offline and click on delete on any client, for that client it disappears while the other client will get the "old" value (the loser of the conflict). When I reload the route/site for the client which "deleted" the doc, the doc will be there again with the "old" value.
This is very confusing, there must be an option or something like that which forces the deletion of a doc, ignoring any conflicts.

@nolanlawson
Copy link
Member

It sounds to me like what's happening here is that deleted conflicts are not being properly propagated from PouchDB to Ember Data. In fact, the behavior you describe is something baked into PouchDB replication, and it works trivially if you use vanilla PouchDB. So that strongly suggests to me that it's the PouchDB -> Ember Data conversion layer that's at fault here.

@nolanlawson nolanlawson changed the title Dealing with delete conflicts Deleted conflicts do not propagate between nodes Feb 22, 2016
@nicozimmermann94
Copy link
Author

So we have to look at the adapter file? Maybe you can give a hint on what I have to look at?

@nolanlawson
Copy link
Member

I would recommend using something like the PouchDB Inspector extension or the IndexedDB view in the Chrome Dev Tools and then comparing it against what you see in your UI. If there's a difference, then the PouchDB -> EmberData mapping is messed up. And yes, that logic can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants