realm-swift: Regression: Sync with MongoDB breaks with Realm 10.5.0

After upgrading from Realm 10.4.0 to 10.5.0, the initial synchronization of a rather large MongoDB (~40,000 rows) database fails after about 20% completion. You can see the error message posted in the log, below.

If I restart the app, it tries to pick up the sync at 20%, but fail immediately. It fails consistently on Realm 10.5, but completes successfully if I downgrade to Realm 10.4.

Goals

Complete initialization of a Realm database from MongoDB

Expected Results

Successful download of the complete database from the cloud.

Actual Results

Sync: Connection[2]: Session[2]: Failed to parse, or apply received changeset: ERROR: ArrayInsert: Invalid prior_size (list size = 18, prior_size = 0)

Exception backtrace:
0   Realm                               0x000000010566b5da _ZNK5realm4sync18InstructionApplier19bad_transaction_logIJmRKjEEEvPKcDpOT_ + 394
1   Realm                               0x000000010566ab77 _ZN5realm4sync18InstructionApplier20resolve_list_elementIRNS_4util8overloadIJZNS1_clERKNS0_5instr11ArrayInsertEE4$_22ZNS1_clES8_E4$_23EEEEEvRNS_7LstBaseEmNSt3__111__wrap_iterIPKN5mpark7variantIJNS0_12InternStringEjEEEEESN_PKcOT_ + 2807
2   Realm                               0x0000000105669c7e _ZN5realm4sync18InstructionApplier13resolve_fieldIRNS_4util8overloadIJZNS1_clERKNS0_5instr11ArrayInsertEE4$_22ZNS1_clES8_E4$_23EEEEEvRNS_3ObjENS0_12InternStringENSt3__111__wrap_iterIPKN5mpark7variantIJSF_jEEEEESN_PKcOT_ + 686
3   Realm                               0x000000010565b117 _ZN5realm4sync18InstructionApplierclERKNS0_5instr11ArrayInsertE + 263
4   Realm                               0x0000000105686954 _ZN5realm4sync18InstructionApplier5applyIS1_EEvRT_RKNS0_9ChangesetEPNS_4util6LoggerE + 100
5   Realm                               0x00000001056823ed _ZN5realm5_impl17ClientHistoryImpl27integrate_server_changesetsERKNS_4sync12SyncProgressEPKyPKNS2_11Transformer15RemoteChangesetEmRNS2_11VersionInfoERNS2_21ClientReplicationBase16IntegrationErrorERNS_4util6LoggerEPNSE_20SyncTransactReporterE + 1053
6   Realm                               0x0000000105695e8d _ZN5realm5_impl14ClientImplBase7Session29initiate_integrate_changesetsEyRKNSt3__16vectorINS_4sync11Transformer15RemoteChangesetENS3_9allocatorIS7_EEEE + 173
7   Realm                               0x00000001056522aa _ZN12_GLOBAL__N_111SessionImpl29initiate_integrate_changesetsEyRKNSt3__16vectorIN5realm4sync11Transformer15RemoteChangesetENS1_9allocatorIS6_EEEE + 42
8   Realm                               0x000000010569497d _ZN5realm5_impl14ClientImplBase7Session24receive_download_messageERKNS_4sync12SyncProgressEyRKNSt3__16vectorINS3_11Transformer15RemoteChangesetENS7_9allocatorISA_EEEE + 589
9   Realm                               0x00000001056918df _ZN5realm5_impl14ClientProtocol22parse_message_receivedINS0_14ClientImplBase10ConnectionEEEvRT_PKcm + 6271
10  Realm                               0x000000010568c0c4 _ZN5realm5_impl14ClientImplBase10Connection33websocket_binary_message_receivedEPKcm + 52
11  Realm                               0x000000010561b413 _ZN12_GLOBAL__N_19WebSocket17frame_reader_loopEv + 1491
12  Realm                               0x000000010569a180 _ZN5realm4util7network7Service9AsyncOper22do_recycle_and_executeINSt3__18functionIFvNS5_10error_codeEmEEEJRS7_RmEEEvbRT_DpOT0_ + 224
13  Realm                               0x0000000105699c44 _ZN5realm4util7network7Service14BasicStreamOpsINS1_3ssl6StreamEE16BufferedReadOperINSt3__18functionIFvNS8_10error_codeEmEEEE19recycle_and_executeEv + 196
14  Realm                               0x0000000105750624 _ZN5realm4util7network7Service4Impl3runEv + 484
15  Realm                               0x00000001056463bd _ZN5realm4sync6Client3runEv + 29
16  Realm                               0x00000001058421dd _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl10SyncClientC1ENS2_INS7_4util6LoggerENS4_ISB_EEEERKNS7_16SyncClientConfigENS_10shared_ptrIKNS7_11SyncManagerEEEEUlvE0_EEEEEPvSN_ + 45
17  libsystem_pthread.dylib             0x00007fff5e740950 _pthread_start + 224
18  libsystem_pthread.dylib             0x00007fff5e73c47b thread_start + 15
Sync: Connection[2]: Connection closed due to error

Version of Realm and Tooling

ProductName:	macOS
ProductVersion:	11.1
BuildVersion:	20C69

/Applications/Xcode 12.2.app/Contents/Developer
Xcode 12.2
Build version 12B45b

/usr/local/bin/pod
1.9.3
(not in use here)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)

/usr/local/bin/carthage
0.36.0
github "realm/realm-cocoa" "v10.5.0"

/usr/bin/git
git version 2.24.3 (Apple Git-128)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (5 by maintainers)

Most upvoted comments

@georgesjamous Because you are a sync user feel free to open a support ticket in the cloud support portal as the github is generally for community support of the non-sync realm sdk is not SLA governed. I can tell you though from your error here:

Sync: Connection[5]: Session[5]: Failed to parse, or apply received changeset: ERROR: ArrayInsert: Invalid prior_size (list size = 2, prior_size = 0)

You are hitting the ArrayMove issue fixed in this release: https://github.com/realm/realm-cocoa/blob/master/CHANGELOG.md#fixed-3

The only way to fix this is to upgrade all your clients to this version and then terminate sync and re-enable on the cloud. Unfortunately, this will cause all your apps to client reset which means they will need to redownload the data from the cloud and start with a fresh slate. Any unsynced data will be lost unless you implement a client reset callback which we always recommend - you can learn more about it here: https://docs.mongodb.com/realm/sdk/android/advanced-guides/client-reset/

Yes its relatively easy to trigger a client reset - Terminate and Re-enable Sync - https://docs.mongodb.com/realm/reference/terminating-and-reenabling-realm-sync/

We’ve digressed from OP - if you have any further questions please take them to forums.realm.io