Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version mismatch does not block sync #6603

Open
HugoBounoua opened this issue Apr 9, 2024 · 5 comments
Open

Version mismatch does not block sync #6603

HugoBounoua opened this issue Apr 9, 2024 · 5 comments
Labels
O-Community T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed

Comments

@HugoBounoua
Copy link

How frequently does the bug occur?

Always

Description

In React Native with synced Realm offline first:
When the Realm schema is updated with breaking changes, even with available migrations, all users who do not update their app before going online with an old local Realm lose all their data.
Nothing (to my knowledge) can prevent the sync from happening, even though the app needs to be updated and the migrations applied first.

Example:
My app is currently in version 1.1.9. The schema has been updated with breaking changes today. Those changes are handled by migrations in the app using "onMigration" function on the RealmProvider if a user updates to version 1.1.9.
If a user was connected last week in version 1.1.8 and stayed offline until today, they will have 2 choices:

  • Stay offline, close the app, update the app which applies the migrations, and open the app -> success
    OR
  • Have the app opened, get an internet signal, Realm will automatically sync with the cloud, schema inconsistency: client reset -> data lost forever

I cannot ask all my clients to check for a new update whenever they find an internet signal.
As far as I know, there is no way to prevent that at the moment, which is a complete blocking point for our product.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

  • Create a Schema
  • Connect with a synced Realm offline first
  • Turn on airplane mode
  • Update critical data locally offline
  • Update the schema with breaking changes on Realm UI
  • Create migrations to adapt local data to the new schema and publish them on the app store
  • Do not update the app and turn on airplane mode: your critical data is lost forever

Version

12.6.2

What services are you using?

Both Atlas Device Sync and Atlas App Services

Are you using encryption?

Yes

Platform OS and version(s)

React Native iOS 17.4

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

Copy link

sync-by-unito bot commented Apr 9, 2024

➤ PM Bot commented:

Jira ticket: RJS-2795

@HugoBounoua
Copy link
Author

@kneth Is there a way to specify a version number to Realm and not allow Realm to sync if there is a version mismatch? A solution to not impact and destroy all data until the app is updated?

@kneth
Copy link
Member

kneth commented Apr 10, 2024

@HugoBounoua I am curious to know if you use RecoverUnsyncedChanges as client reset mode?

v12.6.0 has a upgrade to Realm Core with realm/realm-core#7239. Do you use flexible sync?

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Apr 10, 2024
@nirinchev
Copy link
Member

I'm curious about

Create migrations to adapt local data to the new schema and publish them on the app store

Unless RealmProvider does something I'm not aware of, onMigration should only apply to local Realms and should never get executed for synchronized Realms.

Additionally, server-side schema migrations is not a feature that is enabled by default across all apps yet. Have you requested that it manually gets enabled for your app?

@danieltabacaru
Copy link

Have you requested that it manually gets enabled for your app?

I don't think that's possible yet. Also, this will be done automatically soon by the client if async open is used (so users need connectivity) and the new schema contains the following subset of breaking changes (remove table, remove property, change optional property to required, change required property to optional)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-Community T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed
Projects
None yet
Development

No branches or pull requests

4 participants