-
Type: Task
-
Resolution: Works as Designed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
Goals
Realm Sync normally
Actual Results
Very often crash with this error
terminating with uncaught exception of type realm::MultipleSyncAgents: Multiple sync agents attempted to join the same session
libc++abi.dylib: terminating with uncaught exception of type realm::MultipleSyncAgents: Multiple sync agents attempted to join the same session Exception backtrace: 0 Realm 0x0000000113de1b78 _ZN5realm2DB7do_openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbbNS_9DBOptionsE + 6620 1 Realm 0x0000000113de3870 _ZN5realm2DB4openERNS_11ReplicationENS_9DBOptionsE + 244 2 Realm 0x0000000113de8358 _ZN5realm2DB6createERNS_11ReplicationENS_9DBOptionsE + 392 3 Realm 0x0000000113b9fde8 _ZN5realm5_impl21ClientFileAccessCache4Slot4openEv + 620 4 Realm 0x0000000113bef6fc _ZN12_GLOBAL__N_111SessionImpl12access_realmEv + 28 5 Realm 0x0000000113baa780 _ZN5realm5_impl14ClientImplBase7Session8activateEv + 604 6 Realm 0x0000000113baa41c _ZN5realm5_impl14ClientImplBase10Connection16activate_sessionENSt3__110unique_ptrINS1_7SessionENS3_14default_deleteIS5_EEEE + 244 7 Realm 0x0000000113bebd28 _ZN5realm4util7network7Trigger8ExecOperIZN12_GLOBAL__N_110ClientImplC1ENS_4sync6Client6ConfigEEUlvE_E19recycle_and_executeEv + 2104 8 Realm 0x0000000113cb0bb8 _ZN5realm4util7network7Service4Impl3runEv + 404 9 Realm 0x0000000113be4fb0 _ZN5realm4sync6Client3runEv + 36 10 Realm 0x0000000113b000f0 _ZZN5realm5_impl10SyncClientC1ENSt3__110unique_ptrINS_4util6LoggerENS2_14default_deleteIS5_EEEERKNS_16SyncClientConfigENS2_10shared_ptrIKNS_11SyncManagerEEEENKUlvE0_clEv + 232 11 Realm 0x0000000113afffc0 _ZNSt3__1L8__invokeIZN5realm5_impl10SyncClientC1ENS_10unique_ptrINS1_4util6LoggerENS_14default_deleteIS6_EEEERKNS1_16SyncClientConfigENS_10shared_ptrIKNS1_11SyncManagerEEEEUlvE0_JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSI_DpOSJ_ + 28 12 Realm 0x0000000113afff20 _ZNSt3__1L16__thread_executeINS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEZN5realm5_impl10SyncClientC1ENS1_INS6_4util6LoggerENS3_ISA_EEEERKNS6_16SyncClientConfigENS_10shared_ptrIKNS6_11SyncManagerEEEEUlvE0_JEJEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 32 13 Realm 0x0000000113aff64c _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl10SyncClientC1ENS2_INS7_4util6LoggerENS4_ISB_EEEERKNS7_16SyncClientConfigENS_10shared_ptrIKNS7_11SyncManagerEEEEUlvE0_EEEEEPvSN_ + 116 14 libsystem_pthread.dylib 0x00000001f396ab40 _pthread_start + 320 15 libsystem_pthread.dylib 0x00000001f3973768 thread_start + 8
Code Sample
public static func writeAsync<T: Object>(obj: T) { guard let config = realmConfig else { return } realmQueue.async { autoreleasepool { do { let realm = try? Realm(configuration: config) try realm?.write { realm?.add(obj) } } catch { print("writeAsync error: \(error.localizedDescription)") } } } }
Is there any chance that the mongoDB Sync doesn't cover the realm object writing and sync at the same times?
Version of Realm and Tooling
Realm framework version: 10.2.0
Xcode version: 12.2
iOS/OSX version: iOS 14.2.1