Error saving field: Error Domain=CBLHTTP Code=409 "conflict" UserInfo={NSLocalizedFailureReason=conflict, NSLocalizedDescription=conflict}
2017-06-23 12:13:57.298774-0600 Tap Forms Mac 5[60432:8772572] Conflicted documents: 0
CBLQuery* query = [self.couchDatabase createAllDocumentsQuery];
query.allDocsMode = kCBLOnlyConflicts;
On Jun 23, 2017, at 11:18 AM, Brendan Duddridge <bren...@gmail.com> wrote:How can there be a conflict when saving, but there are no conflicts in the database.
14:29:39.155| Database: {{ Begin transaction (level 1)...
14:29:39.156| Database: PUT _id=fld-f3c90dfa980a435ab72046e1deff8939, _rev=2-387048e2ded3cc92db4332743b9e1221 (allowConflict=0)
14:29:39.156| Database: }} Abort transaction (level 1)
2017-06-23 14:29:39.156099-0600 Tap Forms Mac 5[63365:8908908] Error saving field: Error Domain=CBLHTTP Code=409 "conflict" UserInfo={NSLocalizedFailureReason=conflict, NSLocalizedDescription=conflict}
14:29:39.162| Database: {{ Begin transaction (level 1)...
14:29:39.163| Database: }} Commit transaction (level 1)
2017-06-23 14:29:39.233272-0600 Tap Forms Mac 5[63365:8908908] fetch duration: 0.07708799839019775
2017-06-23 14:29:39.233488-0600 Tap Forms Mac 5[63365:8908908] build models duration: 0.0001810193061828613
14:29:39.720| Database: {{ Begin transaction (level 1)...
14:29:39.720| Database: PUT _id=fld-f3c90dfa980a435ab72046e1deff8939, _rev=2-387048e2ded3cc92db4332743b9e1221 (allowConflict=0)
14:29:39.720| Database: }} Abort transaction (level 1)
2017-06-23 14:29:39.719939-0600 Tap Forms Mac 5[63365:8908908] Error saving models: Error Domain=CBLHTTP Code=409 "conflict" UserInfo={NSLocalizedFailureReason=conflict, NSLocalizedDescription=conflict}
+ (BOOL)saveAllModelsInDatabase:(CBLDatabase *)database error:(NSError**)outError {
if (![NSThread isMainThread]) {
TFFLog(@"Saving all models on a thread that's not MAIN");
}
__block NSError *error = nil;
__block BOOL success = [database saveAllModels:&error];
if (!success) {
// a conflict occurred.
if (error.code == 409) {
dispatch_async(dispatch_get_main_queue(), ^{
success = [database saveAllModels:&error];
if (!success) {
TFFLog(@"Error saving models: %@", error);
}
});
}
*outError = error;
}
return success;
}
15:27:40.365| Database: }} Commit transaction (level 2)
15:27:40.366| Database: DELETE _id=fld-f3c90dfa980a435ab72046e1deff8939, _rev=2-387048e2ded3cc92db4332743b9e1221 (allowConflict=0)
2017-06-23 15:27:40.366285-0600 Tap Forms Mac 5[65574:8990246] error deleting document: Error Domain=CBLHTTP Code=409 "conflict" UserInfo={NSLocalizedFailureReason=conflict, NSLocalizedDescription=conflict}
15:27:40.366| Database: }} Abort transaction (level 1)
So I somehow managed to delete that field model object that was causing the conflict whenever I did batch saves.
I renamed it, but I'm sure I got another conflict error trying to save it. Then I renamed a different field model object in my database and it saved properly because I was not saving all the models at that time. Then when I quit and re-launched my app, the original field causing the trouble was now gone. Strange but true. So now when I batch save other things I'm no longer getting the conflict error.
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/f0e40ce7-0e9d-4441-ab0f-2a51c34a09a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
What do you mean by “renamed”? Document IDs are immutable.
So is this problem specific to bulk-saving models, not when you save them individually?