realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

BadClientFile error message in realm sync after termination

Open andrew-whitmore opened this issue 3 years ago • 7 comments

Goals

For client apps to be able to recover from a sync termination that has happened in realm when they have unsynced data on their applications.

Expected Results

After the sync is recreated I expect that any unsynced changes on client devices are not lost.

Actual Results

Currently when this happens it renders the local realms corrupt and the data in not synced to atlas.

Steps to Reproduce

  • open a realm on the client application
  • go offline
  • add some data to the local realm
  • terminate the sync
  • recreate sync
  • go back online on the client device.
  • Following error message is displayed in realm logs:

client file not found. The server has forgotten about the client-side file presented by the client. This is likely due to using a synchronized realm after terminating and re-enabling sync. Please wipe the file on the client to resume synchronization. { sessionIdent: 7, clientFileIdent: 8170 } (ProtocolErrorCode=208)

The data is therefore lost.

Version of Realm and Tooling

  • Realm JS SDK Version: 10.1.2
  • Node or React Native: ReactNative
  • Client OS & Version: Macos
  • Which debugger for React Native: Chrome

andrew-whitmore avatar Jan 29 '21 16:01 andrew-whitmore

@andrew-whitmore Do you have an error handler in your sync configuration to handle the client reset?

Moreover, you might want to take a look at the code snippet in the api doc - go to initiateClientReset().

kneth avatar Feb 03 '21 08:02 kneth

@kneth - Yes we are using that currently. However I was wondering if there is any plans to handle this automatically? I know that sync termination isn't something that should technically happen very often but It's very painful for us to have to handle copying one realm to another and in some circumstances implement client side conflict resolution. Would be nice if this automatically recovered.

andrew-whitmore avatar Feb 04 '21 18:02 andrew-whitmore

Why do you have to terminate and recreate sync though? Recovering changes after the server history has been wiped is not something that can reliably be done.

nirinchev avatar Feb 04 '21 18:02 nirinchev

@andrew-whitmore

However I was wondering if there is any plans to handle this automatically?

As @nirinchev mentions, it is not trivial to handle all cases reliable. We will eventually add such a feature but it is not on our immediate roadmap.

kneth avatar Feb 05 '21 09:02 kneth

@nirinchev - As stated in my previous comment I am aware this shouldn't technically happen very often, However this did actually happened in our production environment 2 weeks ago and your support team said the only way to get things resumed is to terminated an re-enable sync. Therefore we are putting some DR in place so we don't lose any data for this unfortunate issue.

andrew-whitmore avatar Feb 05 '21 14:02 andrew-whitmore

I've stepped on this on the iOS SDK as well. When the right schema changes have been made on Atlas, it warns you nicely that the "Client Rest" will be sent to all clients, but all I get is the ERROR "Bad client file identifier (IDENT) error, which as far as I can tell, doesn't fire the Client reset handler. The handler would be able to do something about this error, but as it isn't firing, the mobiles are left in a bad state.

Diederikjh avatar Feb 18 '22 06:02 Diederikjh

With v10.11.0 we introduced a new client reset mode (discard all local changes - simply download the server-side Realm) and we are currently working more an advanced client reset mode where we will merge the server-side Realm with local changes if possible.

kneth avatar Sep 02 '22 08:09 kneth

Versions 10.23.0 and 11.1.0 have the new client reset modes. I am closing the issue as we believe these modes will mitigate the issue. If you will experience it, please create a new issue.

kneth avatar Nov 02 '22 15:11 kneth