Sync Realms fails to resync with the server after receiving a BAD_CHANGESET_DOWLOAD


#1

The setup has a a realm sync user running on a Android device with library version 5.8.0 and setup with a ROS server at version 3.17.0. The syncuser is persistent on the device between device reboots (i.e. realm user logout is not called when the app exists on the device to enable offline sync if network is not available not the next app start).

ROS server details:
[realm-core-5.10.1], [realm-sync-3.10.0]

Realm client on Android:
io.realm:realm-gradle-plugin:5.8.0

The client on realm init is on certain occasions receiving a BAD_CHANGESET_DOWNLOAD that is causing the sync realm to stop any subsequent sync even with network connection still available to the ROS. The sync is never established again till the app/device is restarted. (in our case we are running a custom app on a Android device that is the only running application and controls the device power on and power off controls)

The data generated in stored locally and a full sync is done on a subsequent restart of the device/application.

Logs from the client system:
01-12 19:53:51.013 D/REALM_SYNC: Connection[1]: Session[1]: Finished changeset indexing (incoming: 1 changeset(s) / 2 instructions, local: 1 changeset(s) / 4 instructions, conflict group(s): 2)
Connection[1]: Session[1]: Finished transforming 1 local changesets through 1 incoming changesets (4 vs 2 instructions, in 2 conflict groups)
01-12 19:53:51.015 E/REALM_SYNC: Connection[1]: Session[1]: Failed to parse, or apply received changeset: no such row
Exception backtrace:

01-12 19:53:51.015 I/REALM_SYNC: Connection[1]: Connection closed due to error
01-12 19:53:51.016 D/REALM_JNI: error_handler lambda invoked
01-12 19:53:51.019 E/REALM_JAVA: Session Error[realm://192.168.0.10:9080/d8deca7774ea30ee171b42c7ff7413c0/638c027a-ee34-4592-a376-2f9872412df4/kyra]: BAD_CHANGESET_DOWNLOAD(112)
Bad changeset (DOWNLOAD)
01-12 19:53:51.019 D/REALM_SYNC: Connection[1]: Allowing reconnection in 3074183 milliseconds
01-12 19:53:51.020 D/REALM_SYNC: Connection[1]: Session[1]: Progress handler called, downloaded = 750649, downloadable = 750649, uploaded = 23287524, uploadable = 23289021, progress version = 1, snapshot version = 54941
Connection[1]: Session[1]: Progress handler called, downloaded = 750649, downloadable = 750649, uploaded = 23287524, uploadable = 23289021, progress version = 1, snapshot version = 54941

01-12 19:53:51.246 D/REALM_SYNC: Connection[1]: Session[1]: Progress handler called, downloaded = 750649, downloadable = 750649, uploaded = 23287524, uploadable = 23289123, progress version = 1, snapshot version = 54942
01-12 19:53:51.894 D/REALM_SYNC: Connection[1]: Session[1]: Progress handler called, downloaded = 750649, downloadable = 750649, uploaded = 23287524, uploadable = 23289200, progress version = 1, snapshot version = 54943
01-12 19:53:51.929 D/REALM_SYNC: Connection[1]: Session[1]: Progress handler called, downloaded = 750649, downloadable = 750649, uploaded = 23287524, uploadable = 23289277, progress version = 1, snapshot version = 54944
01-12 19:53:51.971 D/REALM_JAVA: Network request (authenticate): 192.168.0.10:9080/auth
01-12 19:53:51.981 2386-2743/D/REALM_JAVA: Network request (authenticate): 192.168.0.10:9080/auth
01-12 19:53:51.981 2386-2740/D/REALM_JNI: Callback to Java requesting token for path
01-12 19:53:51.996 2386-2741/D/REALM_JNI: Callback to Java requesting token for path
01-12 19:53:52.028 2386-2757/D/REALM_JAVA: Network request (authenticate): 192.168.0.10:9080/auth
01-12 19:53:52.056 2386-2739/D/REALM_JNI: Callback to Java requesting token for path
01-12 19:53:52.091 2386-2743/D/REALM_JAVA: AuthenticateResponse. Identity d8deca7774ea30ee171b42c7ff7413c0; Path /__wildcardpermissions
Session[/data/data/com.saturn/files/realm-object-server/d8deca7774ea30ee171b42c7ff7413c0/__wildcardpermissions/__wildcardpermissions]: Access token acquired
01-12 19:53:52.092 2386-2743/D/REALM_JAVA: Scheduling an access_token refresh in 3153599988908 milliseconds
01-12 19:53:52.092 D/REALM_SYNC: Connection[2]: WebSocket::Websocket()
01-12 19:53:52.093 D/REALM_SYNC: Connection[2]: Session[2]: Binding ‘/data/data/com.saturn/files/realm-object-server/d8deca7774ea30ee171b42c7ff7413c0/__wildcardpermissions/__wildcardpermissions’ to ‘/__wildcardpermissions’
Connection[2]: Session[2]: Activating
Opening Realm file: /data/data/com.saturn/files/realm-object-server/d8deca7774ea30ee171b42c7ff7413c0/__wildcardpermissions/__wildcardpermissions
01-12 19:53:52.094 D/REALM_SYNC: Connection[2]: Session[2]: Progress handler called, downloaded = 402, downloadable = 402, uploaded = 0, uploadable = 0, progress version = 0, snapshot version = 15
Connection[2]: Resolving ‘192.168.0.10:9080’
01-12 19:53:52.099 D/REALM_SYNC: Connection[2]: Connecting to endpoint ‘192.168.0.10:9080’ (1/1)
01-12 19:53:52.101 I/REALM_SYNC: Connection[2]: Connected to endpoint ‘192.168.0.10:9080’ (from ‘192.168.0.119:57338’)
01-12 19:53:52.101 D/REALM_SYNC: Connection[2]: WebSocket::initiate_client_handshake()
01-12 19:53:52.102 2386-2757/D/REALM_JAVA: AuthenticateResponse. Identity d8deca7774ea30ee171b42c7ff7413c0; Path /d8deca7774ea30ee171b42c7ff7413c0/__management
Session[/data/data/com.saturn/files/realm-object-server/d8deca7774ea30ee171b42c7ff7413c0/d8deca7774ea30ee171b42c7ff7413c0/__management]: Access token acquired
01-12 19:53:52.103 2386-2757/D/REALM_JAVA: Scheduling an access_token refresh in 3153599988897 milliseconds
01-12 19:53:52.103 D/REALM_SYNC: Connection[3]: WebSocket::Websocket()
Connection[3]: Session[3]: Binding ‘/data/data/com.saturn/files/realm-object-server/d8deca7774ea30ee171b42c7ff7413c0/d8deca7774ea30ee171b42c7ff7413c0/__management’ to ‘/d8deca7774ea30ee171b42c7ff7413c0/__management’
Connection[3]: Session[3]: Activating
Opening Realm file: /data/data/com.saturn/files/realm-object-server/d8deca7774ea30ee171b42c7ff7413c0/d8deca7774ea30ee171b42c7ff7413c0/__management
01-12 19:53:52.104 D/REALM_SYNC: Connection[3]: Session[3]: Progress handler called, downloaded = 2174, downloadable = 2174, uploaded = 6475, uploadable = 6475, progress version = 0, snapshot version = 45
Connection[3]: Resolving ‘192.168.0.10:9080’
01-12 19:53:52.109 D/REALM_SYNC: Connection[3]: Connecting to endpoint ‘192.168.0.10:9080’ (1/1)
01-12 19:53:52.111 I/REALM_SYNC: Connection[3]: Connected to endpoint ‘192.168.0.10:9080’ (from ‘192.168.0.119:57339’)
01-12 19:53:52.111 D/REALM_SYNC: Connection[3]: WebSocket::initiate_client_handshake()
01-12 19:53:52.119 D/REALM_SYNC: Connection[2]: WebSocket::handle_http_response_received()
01-12 19:53:52.120 D/REALM_SYNC: Connection[2]: Will emit a ping in 391084 milliseconds
Connection[2]: Session[2]: Sending: BIND(path=’/__wildcardpermissions’, signed_user_token_size=605, need_client_file_ident=0)
Connection[2]: Session[2]: Sending: IDENT(client_file_ident=7, client_file_ident_salt=3385417242270936505, scan_server_version=3, scan_client_version=0, latest_server_version=3, latest_server_version_salt=9094675312750777905)
01-12 19:53:52.121 D/REALM_SYNC: Connection[2]: Session[2]: Sending: MARK(request_ident=1)
01-12 19:53:52.125 D/REALM_SYNC: Connection[3]: WebSocket::handle_http_response_received()
Connection[3]: Will emit a ping in 316641 milliseconds
Connection[3]: Session[3]: Sending: BIND(path=’/d8deca7774ea30ee171b42c7ff7413c0/__management’, signed_user_token_size=661, need_client_file_ident=0)
01-12 19:53:52.126 D/REALM_SYNC: Connection[3]: Session[3]: Sending: IDENT(client_file_ident=2, client_file_ident_salt=5487713600228292746, scan_server_version=21, scan_client_version=43, latest_server_version=21, latest_server_version_salt=2332559256150343649)
Connection[3]: Session[3]: Sending: MARK(request_ident=1)


#2

@rvadali Looks like your ROS version could use an upgrade - please update to the latest because we have fixed a bunch of these bad changeset errors - if the problem persists please open a ticket at support.realm.io

Bad Changeset induces a Client Reset error that can be caught as explained here -
https://docs.realm.io/sync/using-synced-realms/errors#client-reset


#3

The version in the last update was from testing with ROS server 3.11.0.

The issue is still valid for ROS server at 3.17.0 which is the latest release version. On an initial sync failure, subsequent sync is not attempted even though the network is present.

Current running versions:
([realm-core-5.12.7], [realm-sync-3.14.13])


#4

I just wanted to clarify what you said - the issue still persists after you did perform an upgrade? What version are you running on your client?

If this did persist on newest ROS + client, can you please open a ticket and provide the information requested within this support article?


#5

The client is an android system using the latest version 5.8.0 of the realm plugin. The server is at ROS 3.17.0

We have been able to repeat this a couple of times. The application starts on the device boot complete and realm initialization is one of the first tasks that is done. The network connection (wifi) should have got a lock by this time but there is a possibility of Wifi being in connecting mode. Given that the system is in init phase, we tend to miss some logs even though the Realm logging is set to Trace and the app itself has also been whitelisted to not drop log messages.