-
Notifications
You must be signed in to change notification settings - Fork 298
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
Bug on to-many relationships with Core Data context #1061
Comments
This is related to #903 |
Thanks for the test app. I will checkout the app and look at the issue ASAP. |
We tried to investigate today and we saw that the problem comes from the context stack. All documents are good. On the server too. We think the problem appears when the pull replication gets 2 batches of documents to close each other. One with a team and some players and the other with the rest of the players. And sometimes maybe, the rest of the players could be integrated before the team. That could cause this issue. Is it possible for 2 pull replications to be executed simultaneously? Or are they integrated in a queue? |
There are no ordering guarantees in a replication. The documents pulled from the server could be inserted into the local database in any order. In general the puller is processing docs in the order in which they were last changed on the server, but there are multiple sockets downloading documents in parallel, so you can't predict the order in which they'll be received. |
The problem comes from the - (NSArray*) queryToManyRelation: (NSRelationshipDescription*)relation
forParentKey: (NSString*)parentKey
prefetch: (BOOL)prefetch
outError: (NSError**)outError; It appears when the insertions are in 2 separate batches. For example, we create a new team with 3 players on a device. The other device gets one batch with the team and one player, and the second batch with the 2 new players. Then, the This part of the code is the problem : SInt64 oldLastSequenceIndexed = view.lastSequenceIndexed;
[view updateIndex];
if (view.lastSequenceIndexed == oldLastSequenceIndexed)
return [result allObjects]; Maybe the I don't know what are these indexes and what |
That is the code for optimizing the performance. @mastohhh Does it help the issue if you take that piece of code out? |
Yes, when we comment that piece of code, this works again. |
The reverted code is the code that tries to optmize the query by checking if the index is actually updated or not. It looks like that code doesn't work well in some certain circumstances that need more investigation. #1061
I reverted that code in 1.2.0 release branch. It reverted code doesn't provide much performance optimization anyway. It will get merged to the master branch once we release 1.2.0 branch which should be soon. Thanks for helping checking the issue. |
Since we started working with Couchbase-lite-ios + CBLIncrementalStore, we've had the same problem: To-many relationships are sometimes not up-to-date in the core data contexts. We decided to add a sample app in Couchbase-lite-ios project in order to isolate this problem.
You can test demo app with #1060
You tap quickly several times on the Add button (we do batches of 10 taps), and after a few tries, the count of players on the right won't be in sync on a team.
The text was updated successfully, but these errors were encountered: