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

When a realm file is considered corrupted, give the developer a way to detect and recover #3031

Open
bmunkholm opened this issue Apr 5, 2018 · 4 comments

Comments

@bmunkholm
Copy link
Contributor

bmunkholm commented Apr 5, 2018

Ref: #2258
Today we assert when the realm file seems corrupted. That leaves users with a restarting app that can never recover unless it's reinstalled.
Solutions to this has been discussed at length here: #728

One suggestion could be:
In specific situations when we detect that the file seems corrupt an option could indicate that the file should be backed up and removed the next time it was opened.

  1. corruption is detected, a flag is set to indicate corruption detected. Perhaps by overwriting the header with a cookie.
  2. when opening a file we would check for the cookie, validate that the file is indeed corrupted and throw "corrupted file" exception which the user can use to take a backup of the file, send it to a crash service and delete the file to start over.
@Zhuinden
Copy link

Zhuinden commented Apr 5, 2018

So like https://realm.io/docs/dotnet/2.0.0/api/reference/Realms.Exceptions.RealmInvalidDatabaseException.html but in all APIs?

(and like realm/realm-java#2912 which never happened for some reason)

@finnschiermer
Copy link
Contributor

  1. I'd prefer to rename the realm file, e.g. appending a ".crash" to the file name.

It's important to acknowledge, that we do not know the root cause and there is some chance of building a scheme which would rename (or poison) a perfect realm file, because the bug is elsewhere.

@finnschiermer
Copy link
Contributor

It's tempting to throw an exception full of relevant information instead of asserting. That would allow anyone who catches the exception to take appropriate action. Against it counts that in many cases, we cannot risk continued operation after the error and we know from experience that in many cases such exceptions are just caught and ignored. Not a good combination.

@sync-by-unito
Copy link

sync-by-unito bot commented Mar 24, 2022

➤ Brian Munkholm commented:

We could reuse the current backup solution. It would have to be configurable if backups should be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants