E/REALM_SYNC: Connection[1]: Session[1]: Failed to parse, or apply received changeset

Facing a sync error but there is no information about when it’s got break please help me with this I have more than 10k records in altas I can not able to find it.

E/REALM_SYNC: Connection[1]: Session[1]: Failed to parse, or apply received changeset: ERROR: ArrayInsert: Invalid prior_size (list size = 4, prior_size = 0)

2021-05-20 17:46:04.934 24099-24396/com.reach52.healthcare.debug E/REALM_SYNC: Connection[3]: Session[3]: Failed to parse, or apply received changeset: ERROR: ArrayInsert: Invalid prior_size (list size = 4, prior_size = 0)

Exception backtrace:
<backtrace not supported on this platform>

2021-05-20 17:46:05.034 24099-24396/com.rea.healthcare.debug I/REALM_SYNC: Connection[3]: Connection closed due to error
2021-05-20 17:46:05.035 24099-24396/com.rea.healthcare.debug E/Realm Setup: Received an ObjectServerError.
2021-05-20 17:46:05.035 24099-24396/com.rea.healthcare.debug D/REALM_SYNC: Connection[3]: Allowing reconnection in 3266722 milliseconds
2021-05-20 17:46:05.035 24099-24396/com.rea.healthcare.debug V/REALM_SYNC: Using already open Realm file: /data/user/0/com.reach52.healthcare.debug/files/mongodb-realm/master-appidby/60a4c95914263d500c582c0c/s_101.realm

Hi @kunal_gharate, have you tracked down the issue and/or found a way to reproduce it?

@Andrew_Morgan 1621937309.287 7365-7426/com.reach52.healthcare.debug E/REALM_SYNC: Connection[1]: Session[1]: Failed to parse, or apply received changeset: ERROR: ArrayInsert: Invalid prior_size (list size = 4, prior_size = 0)

I got this issue again but i don’t know how it get produced

I have the same issue Failed to parse, or apply received changeset: ArrayInsert: Invalid prior_size.

Both iOS and Android apps are unable to open Realm for some users because of the error received from the Realm Sync.

Full error:

Connection[1]: Session[1]: Failed to parse, or apply received changeset: ArrayInsert: Invalid prior_size (list size = 3, prior_size = 0) (instruction target: SettingsV2RealmModel[ObjectId{6159ef49872d4b24322a1daa}].ts[0], version: 47, last_integrated_remote_version: 1, origin_file_ident: 211, timestamp: 220174678003)
Exception backtrace:
0   Divtracker                          0x000000010b690676 _ZN5realm4sync17BadChangesetErrorCI1NS_4util22ExceptionWithBacktraceISt13runtime_errorEEIJNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEEEEDpOT_ + 38
1   Divtracker                          0x000000010b68ac92 _ZN5realm4sync12_GLOBAL__N_125throw_bad_transaction_logENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 34
2   Divtracker                          0x000000010b68aa9f _ZNK5realm4sync18InstructionApplier19bad_transaction_logERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 1135
3   Divtracker                          0x000000010b698999 _ZNK5realm4sync18InstructionApplier19bad_transaction_logIJmRKjEEEvPKcDpOT_ + 73
4   Divtracker                          0x000000010b698477 _ZN5realm4sync18InstructionApplier20resolve_list_elementINS_4util8overloadIJZNS1_clERKNS0_5instr11ArrayInsertEE4$_20ZNS1_clES8_E4$_21ZNS1_clES8_E4$_22ZNS1_clES8_E4$_23ZNS1_clES8_E4$_24ZNS1_clES8_E4$_25EEEEEvRNS_7LstBaseEmNSt3__111__wrap_iterIPKN5mpark7variantIJNS0_12InternStringEjEEEEESQ_PKcOT_ + 2871
5   Divtracker                          0x000000010b697439 _ZN5realm4sync18InstructionApplier13resolve_fieldINS_4util8overloadIJZNS1_clERKNS0_5instr11ArrayInsertEE4$_20ZNS1_clES8_E4$_21ZNS1_clES8_E4$_22ZNS1_clES8_E4$_23ZNS1_clES8_E4$_24ZNS1_clES8_E4$_25EEEEEvRNS_3ObjENS0_12InternStringENSt3__111__wrap_iterIPKN5mpark7variantIJSI_jEEEEESQ_PKcOT_ + 1177
6   Divtracker                          0x000000010b68ea2c _ZN5realm4sync18InstructionApplierclERKNS0_5instr11ArrayInsertE + 636
7   Divtracker                          0x000000010b6b16f4 _ZN5realm4sync18InstructionApplier5applyIS1_EEvRT_RKNS0_9ChangesetEPNS_4util6LoggerE + 100
8   Divtracker                          0x000000010b6ae662 _ZN5realm5_impl17ClientHistoryImpl27integrate_server_changesetsERKNS_4sync12SyncProgressEPKyPKNS2_11Transformer15RemoteChangesetEmRNS2_11VersionInfoERNS2_21ClientReplicationBase16IntegrationErrorERNS_4util6LoggerEPNSE_20SyncTransactReporterE + 946
9   Divtracker                          0x000000010b6bff0d _ZN5realm5_impl14ClientImplBase7Session29initiate_integrate_changesetsEyRKNSt3__16vectorINS_4sync11Transformer15RemoteChangesetENS3_9allocatorIS7_EEEE + 173
10  Divtracker                          0x000000010b68572a _ZN12_GLOBAL__N_111SessionImpl29initiate_integrate_changesetsEyRKNSt3__16vectorIN5realm4sync11Transformer15RemoteChangesetENS1_9allocatorIS6_EEEE + 42
11  Divtracker                          0x000000010b6be9bd _ZN5realm5_impl14ClientImplBase7Session24receive_download_messageERKNS_4sync12SyncProgressEyRKNSt3__16vectorINS3_11Transformer15RemoteChangesetENS7_9allocatorISA_EEEE + 589
12  Divtracker                          0x000000010b6bc15d _ZN5realm5_impl14ClientProtocol22parse_message_receivedINS0_14ClientImplBase10ConnectionEEEvRT_PKcm + 5485
13  Divtracker                          0x000000010b6b6bd4 _ZN5realm5_impl14ClientImplBase10Connection33websocket_binary_message_receivedEPKcm + 52
14  Divtracker                          0x000000010b64ce25 _ZN12_GLOBAL__N_19WebSocket17frame_reader_loopEv + 1509
15  Divtracker                          0x000000010b6c39a0 _ZN5realm4util7network7Service9AsyncOper22do_recycle_and_executeINSt3__18functionIFvNS5_10error_codeEmEEEJRS7_RmEEEvbRT_DpOT0_ + 224
16  Divtracker                          0x000000010b6c3464 _ZN5realm4util7network7Service14BasicStreamOpsINS1_3ssl6StreamEE16BufferedReadOperINSt3__18functionIFvNS8_10error_codeEmEEEE19recycle_and_executeEv + 196
17  Divtracker                          0x000000010b6f4784 _ZN5realm4util7network7Service4Impl3runEv + 484
18  Divtracker                          0x000000010b67cb5d _ZN5realm4sync6Client3runEv + 29
19  Divtracker                          0x000000010b822e8d _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl10SyncClientC1ENS2_INS7_4util6LoggerENS4_ISB_EEEERKNS7_16SyncClientConfigENS_8weak_ptrIKNS7_11SyncManagerEEEEUlvE0_EEEEEPvSN_ + 45
20  libsystem_pthread.dylib             0x00007fff6bfee8fc _pthread_start + 224
21  libsystem_pthread.dylib             0x00007fff6bfea443 thread_start + 15

I do not know the exact steps to reproduce. We have the SettingsV2RealmModel model that contains a list of embedded objects. After we deployed this new model and performed data migration from the old V1 format we received several reports from our users that they are unable to start the app. Erasing databases or the whole Realm folder on the client-side didn’t work. I tried to install the fresh app and log in as a user with the problem and I faced the same issue.

We had to terminate sync and start it again. After that, I was able to log in as a previously broken user. Sync termination is a terrible user experience and we don’t have a clean way to perform that on our mobile clients so we can’t do that all the time. Please-please-please fix the issue on your side.

SettingsV2RealmModel scheme:

{
  "properties": {
    "_id": {
      "bsonType": "objectId"
    },
    "_p": {
      "bsonType": "string"
    },
    "ce": {
      "bsonType": "bool"
    },
    "g": {
      "bsonType": "int"
    },
    "t": {
      "bsonType": "double"
    },
    "te": {
      "bsonType": "bool"
    },
    "ts": {
      "bsonType": "array",
      "items": {
        "bsonType": "object",
        "properties": {
          "s": {
            "bsonType": "objectId"
          },
          "t": {
            "bsonType": "double"
          }
        },
        "required": [
          "s",
          "t"
        ],
        "title": "TaxesV2RealmModel"
      }
    }
  },
  "required": [
    "_id",
    "_p"
  ],
  "title": "SettingsV2RealmModel"
}

Also relates to Realm Data delete from atlas but getting this issue

I also have a full log from the device but can’t list it here as it may contain some personal info like tokens/URLs/IDs/etc. Please reach me if that may help in the investigation.

@Anton_P Could you open an issue on Realm Swift and we will take a look into this. Thanks!

That’s also reproduces on the Android so I decided to post it here but no problem will also open an issue for the iOS repo.

Was there any resolution here? I’m seeing a very similar issue.

There is. changeset referencing a document that no longer exists in the collection. I’m gonna terminate synch, but I’ve got a feeling this will pop up again.

Any recent update about this? we also getting the same error time to time.
Our object also has some subdocuments and it is a bit complex object. It is difficult to restart the realm sync it is a multi-tenant app and has lots of partitions. (One per each).