ManuallyRecoverUnsyncedChangesStrategy

Strategy to manually resolve a Client Reset.

A synced realm may need to be reset because the Device Sync encountered an error and had to be restored from a backup, or because it has been too long since the client connected to the server so the server has rotated the logs.

The Client Reset thus occurs because the server does not have all the information required to bring the client fully up to date.

The manual reset process is as follows: the local copy of the realm is copied into a recovery directory for safekeeping and then deleted from the original location. The next time the realm for that URL is opened it will automatically be re-downloaded from Atlas, and can be used as usual.

Data written to the realm after the local copy of itself diverged from the backup remote copy will be present in the local recovery copy of the Realm file. The re-downloaded realm will initially contain only the data present at the time the realm was backed up on the server.

The client reset process can be initiated in one of two ways:

  1. Run ClientResetRequiredException.executeClientReset manually. All Realm instances must be closed before this method is called.

  2. If Client Reset isn't executed manually, it will automatically be carried out the next time all Realm instances have been closed and re-opened. This will most likely be when the app is restarted.

WARNING: Any writes to the Realm file between this callback and Client Reset has been executed, will not be synchronized to Atlas. Those changes will only be present in the backed up file. It is therefore recommended to close all open Realm instances as soon as possible.

Functions

Link copied to clipboard
abstract fun onClientReset(session: SyncSession, exception: ClientResetRequiredException)

Callback that indicates a Client Reset has happened. This should be handled as quickly as possible as any further changes to the realm will not be synchronized with the server and must be moved manually from the backup realm to the new one.