Made breaking changes in DB schema (renamed document property), so client reset is needed. I have implemented ClientResetHandler in realm config (just for logging for now). But none of this handlers get called. Instead I have exception OnSessionError callback when I update subscriptions:
Realms.Sync.Exceptions.SessionException: Invalid query: failed to parse query: unsupported query for table "MyCollection": key "MyOldQueryKey" is not a queryable field
Exception is obvious and self-explanatory.
The question is:
How can I reset the client and what it really means, is it some function responsibility in code, could restart or even physical re-install of the app?
Do I need to make UI prompt for existing users to physical reinstall the app (fresh install works fine)? Only device with previous app version have the issue.
Is there any way to reset the client without reinstalling the app and in what callback stage - ManualResetFallback never get called?
Where does the Realm SDK stores this queryable old_field_name on client side? I'm using .NET SDK.
Read several topics but there is so many options so one can easily lost: https://www.mongodb.com/docs/atlas/app-services/sync/error-handling/client-resets/ https://www.mongodb.com/docs/realm/sdk/dotnet/sync/client-reset/#std-label-dotnet-client-resets
Update:
_config = new FlexibleSyncConfiguration(_app.CurrentUser!)
{
PopulateInitialSubscriptions = realm =>
{
realm.Subscriptions.Add(realm.All<MyCollection>().Where(x => x.OwnerId == ownerId), new SubscriptionOptions { Name = "MyCollection" });
},
ClientResetHandler = new RecoverOrDiscardUnsyncedChangesHandler
{
OnBeforeReset = (beforeReset) => { Log.Trace("OnBeforeReset"); },
OnAfterRecovery = (beforeReset, afterReset) => { Log.Trace("OnAfterRecovery"); },
OnAfterDiscard = (beforeReset, afterReset) => { Log.Trace("OnAfterDiscard"); },
ManualResetFallback = resetException =>
{
// EXPECTED CALL HERE (never happen)!
var didReset = resetException.InitiateClientReset();
if (didReset) // Navigate the user back to the main page
else // Reset failed - notify user that they'll need to update the app
}
},
OnSessionError = (session, error) =>
{
Log.Error(error);
// ENDED UP HERE!!! WHAT'S NEXT?
}
};