Clifton Labrum
Clifton Labrum

Reputation: 14060

Realm Data Sync after Changing Realm Object Server

Before I launch a Realm app that lots of people rely on, I'm trying to get acquainted with all the possible Realm Object Server failure scenarios so that I'm prepared. :)

Let's say I have the ROS deployed successfully on an Ubuntu VPS and everything works great. Then suddenly my VPS provider shuts down and I have to migrate immediately to another.

I push a client app update with a new realm SyncConfiguration with a new server URL and realm URL and it points to a freshly-installed instance of the ROS with no realm data.

When the users' apps connect to the new server and re-authenticate, what happens to their data when they sync?

  1. All their local data syncs and pushes up to the ROS and everything resumes like the situation never happened.
  2. The new ROS overwrites the local realm with no data.
  3. Something else

I know I can do server-side backups (and I will), but I'm just trying to anticipate what a server migration would look like.

Thanks!

Upvotes: 1

Views: 478

Answers (1)

Christian Melchior
Christian Melchior

Reputation: 20126

You will receive an error called Client Reset. This happens when the server and client disagree about the history of the Realm. It a Client Reset happens, it will backup the local file to another location on the device, after which the original file gets deleted so the server state can be synced.

You can read more here: https://realm.io/docs/realm-object-server/#client-recovery-from-a-backup

How to handle it depends a little on what binding you are in, but the overall concept is the same. This is Swift way:https://realm.io/docs/swift/latest/#client-reset

Upvotes: 1

Related Questions