{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1085","repository_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios","labels_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1085/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1085/comments","events_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1085/events","html_url":"https://github.com/couchbase/couchbase-lite-ios/issues/1085","id":130444094,"number":1085,"title":"CBLIS : NSIncrementalStore accessed by multiple context dispatch queues","user":{"login":"pasin","id":801454,"avatar_url":"https://avatars.githubusercontent.com/u/801454?v=3","gravatar_id":"","url":"https://api.github.com/users/pasin","html_url":"https://github.com/pasin","followers_url":"https://api.github.com/users/pasin/followers","following_url":"https://api.github.com/users/pasin/following{/other_user}","gists_url":"https://api.github.com/users/pasin/gists{/gist_id}","starred_url":"https://api.github.com/users/pasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pasin/subscriptions","organizations_url":"https://api.github.com/users/pasin/orgs","repos_url":"https://api.github.com/users/pasin/repos","events_url":"https://api.github.com/users/pasin/events{/privacy}","received_events_url":"https://api.github.com/users/pasin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"pasin","id":801454,"avatar_url":"https://avatars.githubusercontent.com/u/801454?v=3","gravatar_id":"","url":"https://api.github.com/users/pasin","html_url":"https://github.com/pasin","followers_url":"https://api.github.com/users/pasin/followers","following_url":"https://api.github.com/users/pasin/following{/other_user}","gists_url":"https://api.github.com/users/pasin/gists{/gist_id}","starred_url":"https://api.github.com/users/pasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pasin/subscriptions","organizations_url":"https://api.github.com/users/pasin/orgs","repos_url":"https://api.github.com/users/pasin/repos","events_url":"https://api.github.com/users/pasin/events{/privacy}","received_events_url":"https://api.github.com/users/pasin/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-02-01T18:34:48Z","updated_at":"2016-02-09T09:12:48Z","closed_at":null,"body":"Reported by @cflorion in #951, NSFetchResultController called to newValuesForObjectWithID:withContext:error: from the main context's dispatch queue instead of the root's context dispatch queue.\r\n\r\n```\r\nthread #1: tid = 0x20750c, 0x00000001818d44c4 libobjc.A.dylib`protocols() + 4, queue = 'com.apple.main-thread'\r\n    frame #0: 0x00000001818d44c4 libobjc.A.dylib`protocols() + 4\r\n    frame #1: 0x00000001818d6670 libobjc.A.dylib`getProtocol(char const*) + 20\r\n    frame #2: 0x00000001818d8ab8 libobjc.A.dylib`class_conformsToProtocol + 148\r\n    frame #3: 0x00000001818ea2b8 libobjc.A.dylib`-[NSObject conformsToProtocol:] + 52\r\n    frame #4: 0x00000001821933e0 CoreFoundation`-[NSCache setObject:forKey:cost:] + 124\r\n    frame #5: 0x00000001002696f0 CBLIS iOS Test App`-[CBL_SQLiteStorage getDocNumericID:](self=0x000000012764b7b0, _cmd=\"getDocNumericID:\", docID=@\"B8A3A665-9B2A-4316-9004-0BCEBE253436-3007-00000267C85ACA96\") + 384 at CBL_SQLiteStorage.m:753\r\n    frame #6: 0x00000001002687fc CBLIS iOS Test App`-[CBL_SQLiteStorage getDocumentWithID:revisionID:withBody:status:](self=0x000000012764b7b0, _cmd=\"getDocumentWithID:revisionID:withBody:status:\", docID=@\"B8A3A665-9B2A-4316-9004-0BCEBE253436-3007-00000267C85ACA96\", revID=0x0000000000000000, withBody=YES, outStatus=0x000000016fdd00dc) + 124 at CBL_SQLiteStorage.m:628\r\n    frame #7: 0x0000000100212f84 CBLIS iOS Test App`-[CBLDatabase(self=0x000000012764a420, _cmd=\"getDocumentWithID:revisionID:withBody:status:\", docID=@\"B8A3A665-9B2A-4316-9004-0BCEBE253436-3007-00000267C85ACA96\", inRevID=0x0000000000000000, withBody=YES, outStatus=0x000000016fdd00dc) getDocumentWithID:revisionID:withBody:status:] + 168 at CBLDatabase+Internal.m:508\r\n    frame #8: 0x00000001001a57fc CBLIS iOS Test App`-[CBLDocument currentRevision](self=0x00000001277545a0, _cmd=\"currentRevision\") + 152 at CBLDocument.m:114\r\n    frame #9: 0x00000001001a68e4 CBLIS iOS Test App`-[CBLDocument propertyForKey:](self=0x00000001277545a0, _cmd=\"propertyForKey:\", key=@\"type\") + 68 at CBLDocument.m:244\r\n    frame #10: 0x000000010003488c CBLIS iOS Test App`-[CBLIncrementalStore newValuesForObjectWithID:withContext:error:](self=0x0000000127622eb0, _cmd=\"newValuesForObjectWithID:withContext:error:\", objectID=0x000000012768f3a0, context=0x000000012757a770, outError=domain: nil - code: 6171722688) + 276 at CBLIncrementalStore.m:499\r\n    frame #11: 0x0000000183d934f4 CoreData`__95-[NSPersistentStoreCoordinator(_NSInternalMethods) newValuesForObjectWithID:withContext:error:]_block_invoke + 68\r\n    frame #12: 0x0000000183d99d58 CoreData`gutsOfBlockToNSPersistentStoreCoordinatorPerform + 176\r\n    frame #13: 0x0000000183d8c5c8 CoreData`_perform + 204\r\n    frame #14: 0x0000000183cdcb5c CoreData`-[NSPersistentStoreCoordinator(_NSInternalMethods) newValuesForObjectWithID:withContext:error:] + 160\r\n    frame #15: 0x0000000183d6b234 CoreData`__92-[NSManagedObjectContext(_NestedContextSupport) newValuesForObjectWithID:withContext:error:]_block_invoke + 720\r\n    frame #16: 0x0000000183d5c76c CoreData`_perform + 324\r\n    frame #17: 0x0000000183d6af24 CoreData`-[NSManagedObjectContext(_NestedContextSupport) newValuesForObjectWithID:withContext:error:] + 132\r\n    frame #18: 0x0000000183cdc1c8 CoreData`_PFFaultHandlerLookupRow + 336\r\n    frame #19: 0x0000000183cdbc74 CoreData`_PF_FulfillDeferredFault + 244\r\n    frame #20: 0x0000000183cdba7c CoreData`_sharedIMPL_pvfk_core + 116\r\n    frame #21: 0x0000000183ceb568 CoreData`_PF_Handler_Public_GetProperty + 276\r\n    frame #22: 0x0000000182c1c990 Foundation`-[NSSortDescriptor compareObject:toObject:] + 132\r\n    frame #23: 0x0000000183cf3dd4 CoreData`+[NSFetchedResultsController(PrivateMethods) _insertIndexForObject:inArray:lowIdx:highIdx:sortDescriptors:] + 272\r\n    frame #24: 0x0000000183cf3c14 CoreData`-[NSFetchedResultsController(PrivateMethods) _postprocessInsertedObjects:] + 588\r\n    frame #25: 0x0000000183debec0 CoreData`__77-[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]_block_invoke + 2060\r\n    frame #26: 0x0000000183d61080 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 196\r\n    frame #27: 0x0000000183d60f48 CoreData`-[NSManagedObjectContext performBlockAndWait:] + 220\r\n    frame #28: 0x0000000183cf1108 CoreData`-[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 116\r\n    frame #29: 0x0000000182206fc4 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20\r\n    frame #30: 0x00000001822067e4 CoreFoundation`_CFXRegistrationPost + 396\r\n    frame #31: 0x0000000182206564 CoreFoundation`___CFXNotificationPost_block_invoke + 60\r\n    frame #32: 0x000000018226bde4 CoreFoundation`-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1532\r\n    frame #33: 0x00000001821470f4 CoreFoundation`_CFXNotificationPost + 368\r\n    frame #34: 0x0000000182b36d2c Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 68\r\n    frame #35: 0x0000000183cf106c CoreData`-[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 80\r\n    frame #36: 0x0000000183d658d0 CoreData`-[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:] + 1212\r\n    frame #37: 0x0000000183cef78c CoreData`-[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 2512\r\n    frame #38: 0x0000000183cee240 CoreData`-[NSManagedObjectContext save:] + 168\r\n    frame #39: 0x0000000100049bd8 CBLIS iOS Test App`__31-[AppDelegateCBLIS saveContext]_block_invoke(.block_descriptor=<unavailable>) + 96 at AppDelegateCBLIS.m:104\r\n    frame #40: 0x0000000183d61080 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 196\r\n    frame #41: 0x00000001005ddbb0 libdispatch.dylib`_dispatch_client_callout + 16\r\n    frame #42: 0x00000001005e3658 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 2096\r\n    frame #43: 0x0000000182218bb0 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12\r\n    frame #44: 0x0000000182216a18 CoreFoundation`__CFRunLoopRun + 1628\r\n    frame #45: 0x0000000182145680 CoreFoundation`CFRunLoopRunSpecific + 384\r\n    frame #46: 0x0000000183654088 GraphicsServices`GSEventRunModal + 180\r\n    frame #47: 0x0000000186fbcd90 UIKit`UIApplicationMain + 204\r\n    frame #48: 0x000000010004a300 CBLIS iOS Test App`main(argc=1, argv=0x000000016fdd3ac8) + 124 at mainCBLIS.m:16\r\n    frame #49: 0x0000000181ce68b8 libdyld.dylib`start + 4\r\n\r\n  thread #2: tid = 0x207523, 0x0000000181e054fc libsystem_kernel.dylib`kevent_qos + 8, queue = 'com.apple.libdispatch-manager'\r\n    frame #0: 0x0000000181e054fc libsystem_kernel.dylib`kevent_qos + 8\r\n    frame #1: 0x00000001005f2270 libdispatch.dylib`_dispatch_mgr_invoke + 232\r\n    frame #2: 0x00000001005dfe2c libdispatch.dylib`_dispatch_mgr_thread + 52\r\n\r\n  thread #7: tid = 0x207527, 0x0000000181e03ffc libsystem_kernel.dylib`__psynch_rw_rdlock + 8, name = 'CouchbaseLite'\r\n    frame #0: 0x0000000181e03ffc libsystem_kernel.dylib`__psynch_rw_rdlock + 8\r\n    frame #1: 0x0000000181ec987c libsystem_pthread.dylib`_pthread_rwlock_lock + 412\r\n    frame #2: 0x00000001001e8678 CBLIS iOS Test App`-[MYReadWriteLock lock](self=0x0000000127614b90, _cmd=\"lock\") + 48 at MYReadWriteLock.m:39\r\n    frame #3: 0x0000000100281724 CBLIS iOS Test App`-[CBL_FMDatabase acquireReadLock](self=0x00000001275793f0, _cmd=\"acquireReadLock\") + 100 at FMDatabase.m:225\r\n    frame #4: 0x00000001002831dc CBLIS iOS Test App`-[CBL_FMDatabase executeQuery:withArgumentsInArray:orVAList:](self=0x00000001275793f0, _cmd=\"executeQuery:withArgumentsInArray:orVAList:\", sql=@\"SELECT doc_id FROM docs WHERE docid=?\", arrayArgs=0x0000000000000000, args=\"\\340\\306\"\\x9b\\x01\") + 1752 at FMDatabase.m:697\r\n    frame #5: 0x0000000100284d48 CBLIS iOS Test App`-[CBL_FMDatabase(self=0x00000001275793f0, _cmd=\"longLongForQuery:\", query=@\"SELECT doc_id FROM docs WHERE docid=?\") longLongForQuery:] + 76 at FMDatabaseAdditions.m:37\r\n    frame #6: 0x0000000100269650 CBLIS iOS Test App`-[CBL_SQLiteStorage getDocNumericID:](self=0x00000001275793b0, _cmd=\"getDocNumericID:\", docID=@\"32DEC851-C93A-48C9-B9F9-C4C6F375995B-5475-00000449AE9D6152\") + 224 at CBL_SQLiteStorage.m:750\r\n    frame #7: 0x00000001002691a4 CBLIS iOS Test App`-[CBL_SQLiteStorage loadRevisionBody:](self=0x00000001275793b0, _cmd=\"loadRevisionBody:\", rev=0x00000001276b3f40) + 492 at CBL_SQLiteStorage.m:707\r\n    frame #8: 0x00000001002132f0 CBLIS iOS Test App`-[CBLDatabase(self=0x00000001275787f0, _cmd=\"loadRevisionBody:\", rev=0x00000001276b3f40) loadRevisionBody:] + 620 at CBLDatabase+Internal.m:532\r\n    frame #9: 0x00000001002134d0 CBLIS iOS Test App`-[CBLDatabase(self=0x00000001275787f0, _cmd=\"revisionByLoadingBody:status:\", rev=0x00000001275f5030, outStatus=0x000000016e2453dc) revisionByLoadingBody:status:] + 432 at CBLDatabase+Internal.m:548\r\n    frame #10: 0x0000000100166938 CBLIS iOS Test App`__30-[CBLRestPusher processInbox:]_block_invoke(.block_descriptor=<unavailable>, results=0 key/value pairs, error=0x0000000000000000) + 1012 at CBLRestPusher.m:237\r\n    frame #11: 0x0000000100159658 CBLIS iOS Test App`__61-[CBLRestReplicator sendAsyncRequest:path:body:onCompletion:]_block_invoke(.block_descriptor=<unavailable>, result=0 key/value pairs, error=0x0000000000000000) + 444 at CBLRestReplicator.m:690\r\n    frame #12: 0x0000000100179fec CBLIS iOS Test App`-[CBLRemoteRequest respondWithResult:error:](self=0x0000000127726700, _cmd=\"respondWithResult:error:\", result=0 key/value pairs, error=0x0000000000000000) + 224 at CBLRemoteRequest.m:179\r\n    frame #13: 0x000000010017c998 CBLIS iOS Test App`-[CBLRemoteJSONRequest connectionDidFinishLoading:](self=0x0000000127726700, _cmd=\"connectionDidFinishLoading:\", connection=0x000000012773bf10) + 808 at CBLRemoteRequest.m:506\r\n    frame #14: 0x00000001829ca6ec CFNetwork`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 80\r\n    frame #15: 0x00000001829ca67c CFNetwork`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 200\r\n    frame #16: 0x00000001829ca7f0 CFNetwork`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56\r\n    frame #17: 0x000000018283731c CFNetwork`___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 100\r\n    frame #18: 0x0000000182924e7c CFNetwork`___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 108\r\n    frame #19: 0x00000001005ddbb0 libdispatch.dylib`_dispatch_client_callout + 16\r\n    frame #20: 0x00000001005e7354 libdispatch.dylib`_dispatch_block_invoke + 564\r\n    frame #21: 0x0000000182823a88 CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 36\r\n    frame #22: 0x00000001821450ac CoreFoundation`CFArrayApplyFunction + 68\r\n    frame #23: 0x000000018282396c CFNetwork`RunloopBlockContext::perform() + 136\r\n    frame #24: 0x000000018282382c CFNetwork`MultiplexerSource::perform() + 312\r\n    frame #25: 0x0000000182823658 CFNetwork`MultiplexerSource::_perform(void*) + 68\r\n    frame #26: 0x0000000182218efc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24\r\n    frame #27: 0x0000000182218990 CoreFoundation`__CFRunLoopDoSources0 + 540\r\n    frame #28: 0x0000000182216690 CoreFoundation`__CFRunLoopRun + 724\r\n    frame #29: 0x0000000182145680 CoreFoundation`CFRunLoopRunSpecific + 384\r\n    frame #30: 0x0000000182b3d21c Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 308\r\n    frame #31: 0x0000000100151b5c CBLIS iOS Test App`-[CBL_RunLoopServer runServerThread](self=0x0000000127575a50, _cmd=\"runServerThread\") + 512 at CBL_Server.m:190\r\n    frame #32: 0x0000000182c23c40 Foundation`__NSThread__start__ + 1000\r\n    frame #33: 0x0000000181ecbb28 libsystem_pthread.dylib`_pthread_body + 156\r\n    frame #34: 0x0000000181ecba8c libsystem_pthread.dylib`_pthread_start + 156\r\n\r\n  thread #8: tid = 0x207535, 0x0000000181de94bc libsystem_kernel.dylib`mach_msg_trap + 8, name = 'com.apple.NSURLConnectionLoader'\r\n    frame #0: 0x0000000181de94bc libsystem_kernel.dylib`mach_msg_trap + 8\r\n    frame #1: 0x0000000181de9338 libsystem_kernel.dylib`mach_msg + 72\r\n    frame #2: 0x0000000182218ac0 CoreFoundation`__CFRunLoopServiceMachPort + 196\r\n    frame #3: 0x00000001822167c4 CoreFoundation`__CFRunLoopRun + 1032\r\n    frame #4: 0x0000000182145680 CoreFoundation`CFRunLoopRunSpecific + 384\r\n    frame #5: 0x00000001828b5434 CFNetwork`+[NSURLConnection(Loader) _resourceLoadLoop:] + 412\r\n    frame #6: 0x0000000182c23c40 Foundation`__NSThread__start__ + 1000\r\n    frame #7: 0x0000000181ecbb28 libsystem_pthread.dylib`_pthread_body + 156\r\n    frame #8: 0x0000000181ecba8c libsystem_pthread.dylib`_pthread_start + 156\r\n\r\n  thread #9: tid = 0x207536, 0x0000000181e04368 libsystem_kernel.dylib`__select + 8, name = 'com.apple.CFSocket.private'\r\n    frame #0: 0x0000000181e04368 libsystem_kernel.dylib`__select + 8\r\n    frame #1: 0x000000018221f028 CoreFoundation`__CFSocketManager + 648\r\n    frame #2: 0x0000000181ecbb28 libsystem_pthread.dylib`_pthread_body + 156\r\n    frame #3: 0x0000000181ecba8c libsystem_pthread.dylib`_pthread_start + 156\r\n\r\n  thread #10: tid = 0x2075ba, 0x0000000181e04b6c libsystem_kernel.dylib`__workq_kernreturn + 8\r\n    frame #0: 0x0000000181e04b6c libsystem_kernel.dylib`__workq_kernreturn + 8\r\n    frame #1: 0x0000000181ec9530 libsystem_pthread.dylib`_pthread_wqthread + 1284\r\n\r\n* thread #6: tid = 0x2075c0, 0x0000000100281e78 CBLIS iOS Test App`-[CBL_FMDatabase warnInUse](self=0x000000012756f7c0, _cmd=\"warnInUse\") + 20 at FMDatabase.m:356, queue = 'NSPersistentStoreCoordinator 0x12756a700', stop reason = breakpoint 1.1\r\n  * frame #0: 0x0000000100281e78 CBLIS iOS Test App`-[CBL_FMDatabase warnInUse](self=0x000000012756f7c0, _cmd=\"warnInUse\") + 20 at FMDatabase.m:356\r\n    frame #1: 0x00000001002840d0 CBLIS iOS Test App`-[CBL_FMDatabase beginUse](self=0x000000012756f7c0, _cmd=\"beginUse\") + 336 at FMDatabase.m:974\r\n    frame #2: 0x0000000100282c34 CBLIS iOS Test App`-[CBL_FMDatabase executeQuery:withArgumentsInArray:orVAList:](self=0x000000012756f7c0, _cmd=\"executeQuery:withArgumentsInArray:orVAList:\", sql=@\"SELECT lastSequence FROM views WHERE name=?\", arrayArgs=0x0000000000000000, args=\"\\300 R'\\x01\") + 304 at FMDatabase.m:603\r\n    frame #3: 0x0000000100284d48 CBLIS iOS Test App`-[CBL_FMDatabase(self=0x000000012756f7c0, _cmd=\"longLongForQuery:\", query=@\"SELECT lastSequence FROM views WHERE name=?\") longLongForQuery:] + 76 at FMDatabaseAdditions.m:37\r\n    frame #4: 0x00000001002774cc CBLIS iOS Test App`-[CBL_SQLiteViewStorage lastSequenceIndexed](self=0x0000000127535050, _cmd=\"lastSequenceIndexed\") + 152 at CBL_SQLiteViewStorage.m:248\r\n    frame #5: 0x0000000100178830 CBLIS iOS Test App`-[CBLView lastSequenceIndexed](self=0x000000012754bec0, _cmd=\"lastSequenceIndexed\") + 60 at CBLView.m:338\r\n    frame #6: 0x0000000100040710 CBLIS iOS Test App`-[CBLIncrementalStore queryToManyRelation:forParentKey:prefetch:outError:](self=0x0000000127622eb0, _cmd=\"queryToManyRelation:forParentKey:prefetch:outError:\", relation=0x0000000127558ca0, parentKey=@\"6E8CFE10-CBCA-4CB8-9AF5-F1921F29DC12-2538-00000209AA965B3B\", prefetch=NO, outError=domain: nil - code: 6141692128) + 572 at CBLIncrementalStore.m:1655\r\n    frame #7: 0x000000010003546c CBLIS iOS Test App`__81-[CBLIncrementalStore newValueForRelationship:forObjectWithID:withContext:error:]_block_invoke(.block_descriptor=0x000000016e12c588) + 164 at CBLIncrementalStore.m:539\r\n    frame #8: 0x0000000183d61080 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 196\r\n    frame #9: 0x0000000183d60f48 CoreData`-[NSManagedObjectContext performBlockAndWait:] + 220\r\n    frame #10: 0x0000000100035078 CBLIS iOS Test App`-[CBLIncrementalStore newValueForRelationship:forObjectWithID:withContext:error:](self=0x0000000127622eb0, _cmd=\"newValueForRelationship:forObjectWithID:withContext:error:\", relationship=0x0000000127558ca0, objectID=0x00000001275790f0, context=0x000000012756d560, outError=domain: nil - code: 6141692128) + 1412 at CBLIncrementalStore.m:537\r\n    frame #11: 0x0000000183d93654 CoreData`__110-[NSPersistentStoreCoordinator(_NSInternalMethods) newValueForRelationship:forObjectWithID:withContext:error:]_block_invoke + 72\r\n    frame #12: 0x0000000183d99d58 CoreData`gutsOfBlockToNSPersistentStoreCoordinatorPerform + 176\r\n    frame #13: 0x0000000183d8c5c8 CoreData`_perform + 204\r\n    frame #14: 0x0000000183cf7558 CoreData`-[NSPersistentStoreCoordinator(_NSInternalMethods) newValueForRelationship:forObjectWithID:withContext:error:] + 160\r\n    frame #15: 0x0000000183cf7358 CoreData`-[NSFaultHandler retainedFulfillAggregateFaultForObject:andRelationship:withContext:] + 660\r\n    frame #16: 0x0000000183d18140 CoreData`-[_NSFaultingMutableSet willReadWithContents:] + 420\r\n    frame #17: 0x0000000183cfa024 CoreData`-[_NSFaultingMutableSet count] + 28\r\n    frame #18: 0x0000000183d02214 CoreData`+[_PFRoutines newMutableSetFromCollection:byRemovingItems:] + 96\r\n    frame #19: 0x0000000183d56d9c CoreData`-[NSManagedObject(_NSInternalMethods) _updateFromRefreshSnapshot:includingTransients:] + 996\r\n    frame #20: 0x0000000183d0ac58 CoreData`-[NSManagedObjectContext refreshObject:mergeChanges:] + 956\r\n    frame #21: 0x00000001000375e0 CBLIS iOS Test App`-[CBLIncrementalStore notifyNewRevisionForManagedObject:withRevId:withContext:](self=0x0000000127622eb0, _cmd=\"notifyNewRevisionForManagedObject:withRevId:withContext:\", object=0x0000000127641220, revId=@\"232-f6d13112777ee794d486c246c794d2da\", context=0x000000012756d560) + 492 at CBLIncrementalStore.m:711\r\n    frame #22: 0x00000001000372ac CBLIS iOS Test App`-[CBLIncrementalStore insertOrUpdateObject:withContext:outError:](self=0x0000000127622eb0, _cmd=\"insertOrUpdateObject:withContext:outError:\", object=0x0000000127641220, context=0x000000012756d560, outError=domain: nil - code: 4955836960) + 2260 at CBLIncrementalStore.m:692\r\n    frame #23: 0x0000000100036480 CBLIS iOS Test App`__63-[CBLIncrementalStore executeSaveRequest:withContext:outError:]_block_invoke(.block_descriptor=<unavailable>) + 984 at CBLIncrementalStore.m:632\r\n    frame #24: 0x00000001001b7ddc CBLIS iOS Test App`__29-[CBLDatabase inTransaction:]_block_invoke(.block_descriptor=<unavailable>) + 40 at CBLDatabase.m:192\r\n    frame #25: 0x0000000100268364 CBLIS iOS Test App`-[CBL_SQLiteStorage inTransaction:](self=0x000000012764b7b0, _cmd=\"inTransaction:\", block=(CBLIS iOS Test App`__29-[CBLDatabase inTransaction:]_block_invoke at CBLDatabase.m:191)) + 148 at CBL_SQLiteStorage.m:579\r\n    frame #26: 0x00000001001b7d60 CBLIS iOS Test App`-[CBLDatabase inTransaction:](self=0x000000012764a420, _cmd=\"inTransaction:\", block=(CBLIS iOS Test App`__63-[CBLIncrementalStore executeSaveRequest:withContext:outError:]_block_invoke at CBLIncrementalStore.m:622)) + 176 at CBLDatabase.m:191\r\n    frame #27: 0x0000000100036018 CBLIS iOS Test App`-[CBLIncrementalStore executeSaveRequest:withContext:outError:](self=0x0000000127622eb0, _cmd=\"executeSaveRequest:withContext:outError:\", request=0x00000001275cf5b0, context=0x000000012756d560, outError=domain: nil - code: 4955836960) + 288 at CBLIncrementalStore.m:622\r\n    frame #28: 0x0000000100035cfc CBLIS iOS Test App`-[CBLIncrementalStore executeRequest:withContext:error:](self=0x0000000127622eb0, _cmd=\"executeRequest:withContext:error:\", request=0x00000001275cf5b0, context=0x000000012756d560, outError=domain: nil - code: 4955836960) + 184 at CBLIncrementalStore.m:589\r\n    frame #29: 0x0000000183d91d5c CoreData`__65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 3724\r\n    frame #30: 0x0000000183d99d58 CoreData`gutsOfBlockToNSPersistentStoreCoordinatorPerform + 176\r\n    frame #31: 0x00000001005ddbb0 libdispatch.dylib`_dispatch_client_callout + 16\r\n    frame #32: 0x00000001005e9764 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 164\r\n    frame #33: 0x0000000183d8c5b0 CoreData`_perform + 180\r\n    frame #34: 0x0000000183cc9e70 CoreData`-[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 300\r\n    frame #35: 0x0000000183cee624 CoreData`-[NSManagedObjectContext save:] + 1164\r\n    frame #36: 0x0000000100049d04 CBLIS iOS Test App`__31-[AppDelegateCBLIS saveContext]_block_invoke_2(.block_descriptor=<unavailable>) + 92 at AppDelegateCBLIS.m:106\r\n    frame #37: 0x0000000183d61080 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 196\r\n    frame #38: 0x00000001005ddbb0 libdispatch.dylib`_dispatch_client_callout + 16\r\n    frame #39: 0x00000001005ea6c8 libdispatch.dylib`_dispatch_queue_drain + 1036\r\n    frame #40: 0x00000001005e18a0 libdispatch.dylib`_dispatch_queue_invoke + 464\r\n    frame #41: 0x00000001005ddbb0 libdispatch.dylib`_dispatch_client_callout + 16\r\n    frame #42: 0x00000001005ece10 libdispatch.dylib`_dispatch_root_queue_drain + 2344\r\n    frame #43: 0x00000001005ec4d8 libdispatch.dylib`_dispatch_worker_thread3 + 132\r\n    frame #44: 0x0000000181ec9470 libsystem_pthread.dylib`_pthread_wqthread + 1092\r\n\r\n  thread #11: tid = 0x2075c1, 0x0000000181e04b6c libsystem_kernel.dylib`__workq_kernreturn + 8\r\n    frame #0: 0x0000000181e04b6c libsystem_kernel.dylib`__workq_kernreturn + 8\r\n    frame #1: 0x0000000181ec9530 libsystem_pthread.dylib`_pthread_wqthread + 1284\r\n```"},"comment":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/comments/181771866","html_url":"https://github.com/couchbase/couchbase-lite-ios/issues/1085#issuecomment-181771866","issue_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1085","id":181771866,"user":{"login":"mastohhh","id":1760064,"avatar_url":"https://avatars.githubusercontent.com/u/1760064?v=3","gravatar_id":"","url":"https://api.github.com/users/mastohhh","html_url":"https://github.com/mastohhh","followers_url":"https://api.github.com/users/mastohhh/followers","following_url":"https://api.github.com/users/mastohhh/following{/other_user}","gists_url":"https://api.github.com/users/mastohhh/gists{/gist_id}","starred_url":"https://api.github.com/users/mastohhh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mastohhh/subscriptions","organizations_url":"https://api.github.com/users/mastohhh/orgs","repos_url":"https://api.github.com/users/mastohhh/repos","events_url":"https://api.github.com/users/mastohhh/events{/privacy}","received_events_url":"https://api.github.com/users/mastohhh/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T09:12:48Z","updated_at":"2016-02-09T09:12:48Z","body":"I tried to replace the main context with the root when called from the main, didn't work.\r\n\r\nI tried `[self.database doSync:]` and `[self.database doAsync:]` methods, didn't work.\r\n\r\nI tried a `dispatch_semaphore_t` for the `doAsync:`, didn't work too.\r\n\r\nI tried combinations of these, didn't work.\r\n\r\nSo `@synchronized(self)` did it."}}