Hello again, I am sure this is something we caused internally - I just don't know what. :(
Scenario: we are currently building a product and during the development phase we need to periodically delete all documents for testing. We therefore implemented a quick and dirty delete function that simple wipes all existing documents in the database. We cannot just delete the local data as the changes would replicate down from the remote database again. However when running the delete function it seems that something causes the sync gateway to throw the following error: 10:23:59.477‖ WARNING: CBL_Pusher[http://sync.dev.appmonkie.com/default]: _bulk_docs got an error: { error = 500; id = "account:[email protected]"; reason = "Exception in JS sync function"; status = 500; } >From this moment on synchronization doesn't work anymore - with the every push the same error occurs. Only when deleting the local database (mobile device) we can start the replication but then it seems that the remote documents are still there. In a nutshell it seems that the delete function causes a conflict in the database and prevents the changes to be pushed upstream. Looking at the sync gateway logs it seems that the gateway has issue with the channels. My theory is that due to the deletion of the documents the channel is invalidated but I am not sure whether this would cause this error. Sync Gateway: 19:48:21.848881 HTTP: #2064: POST /default/_bulk_docs (as [email protected]) 19:48:21.851336 WARNING: Sync fn exception: TypeError; doc = map[owner: [email protected] _id:account:[email protected] created_at:2014-11-17T19:48:21.309Z name:Test _revisions:map[ids:[ca9dbffd62a5728a5317ecadbe96c1c6 50b6701430f66b36be95eb866d4d5137] start:%!s(float64=19)] status:new _rev:19-ca9dbffd62a5728a5317ecadbe96c1c6 type:account updated_at:2014-11-17T19:48:21.309Z] -- db.(*Database).getChannelsAndAccess() at crud.go:715 Excerpt from gateway config: else if (doc.type == "account") { var username = doc._id.substring(doc._id.indexOf(":")+1); channel("account-"+username); if (!doc.owner) { throw({forbidden : "account must have an owner"}) } if (oldDoc) { var oldOwnerName = oldDoc.owner.substring(oldDoc.owner.indexOf(":")+1); requireUser(oldOwnerName) } // set access permissions for owner and members var ownerName = doc.owner.substring(doc.owner.indexOf(":")+1); access(ownerName, "account-"+username); if (Array.isArray(doc.members)) { var memberNames = []; for (var i = doc.members.length - 1; i >= 0; i--) {memberNames.push(doc.members[i].substring(doc.members[i].indexOf(":")+1))}; access(memberNames, "account-"+username); } } Delete function: CBLQuery *query = [[OPDatabase getSharedDatabaseInstance].dataBaseInstance createAllDocumentsQuery]; CBLQueryEnumerator *result = [query run:nil]; for (CBLQueryRow *row in result) { NSError *error; NSLog(@"Deleting doc id: %@", row.documentID); [row.document deleteDocument:&error]; if (error) NSLog(@"Error: %@", error.userInfo); } Please keep in mind that this function is only for dev purposes and not really important - but it would be great to understand what is happening here. Thanks as always Christoph -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/bb75d9fb-49c5-4830-9c4a-3fa1937e222d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
