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

Bundling sqlite can cause data corruption on Android N and later #166

Open
M66B opened this issue Sep 27, 2022 · 7 comments
Open

Bundling sqlite can cause data corruption on Android N and later #166

M66B opened this issue Sep 27, 2022 · 7 comments

Comments

@M66B
Copy link
Contributor

M66B commented Sep 27, 2022

Please see here for the details:

https://ericsink.com/entries/sqlite_android_n.html

Since more and more people were reporting losing all data, especially on Redmi, OnePlus and Oppo devices, I stopped bundling sqlite. See also here:

https://forum.xda-developers.com/t/app-5-0-fairemail-fully-featured-open-source-privacy-oriented-email-app.3824168/post-87494245

IMHO there should be a warning about this in the description of this library.

@npurushe
Copy link
Contributor

Could you share what about Android N causes an issue? this library doesn't link against the system sqlite version, instead it contains its own separate version. There is a another issue mentioned that is maybe more relevant about multiple sqlite instances linked to an app, I think that is true you should avoid using the Android OS sqlite APIs and this libraries APIs on the same db file at the same time but that is true for any Android OS version. Is that the issue you think you were seeing ?

@M66B
Copy link
Contributor Author

M66B commented Sep 27, 2022

Please see here for what I know, which is not much, unfortunately:

https://github.com/M66B/FairEmail/blob/master/FAQ.md#redmi

I am not 100% sure if this is the issue, though. With the data gone, debugging and error reporting become hard, not to say impossible.

I can say it is happening more often than before, possibly because the number of people using Android N or later is increasing.

I also know that, for example, the Android work manager uses sqlite as well.

@M66B
Copy link
Contributor Author

M66B commented Sep 27, 2022

There is some more information here:

https://ericsink.com/entries/multiple_sqlite_problem.html

@M66B
Copy link
Contributor Author

M66B commented Sep 27, 2022

Linking two sqlite libraries (requery's and Android's) is known to result in occasional corruption:

https://sqlite.org/howtocorrupt.html#multiple_copies_of_sqlite_linked_into_the_same_application

There is a proof of concept here:

https://github.com/jeremysheeley/Android_N_SQLite_Corruption

@npurushe
Copy link
Contributor

For those cases the two instances have to be operating on the same database file. As long as you ensure you are not using both apis concurrently on the same database file there should be no issue.

@M66B
Copy link
Contributor Author

M66B commented Sep 28, 2022

That was my thought too, but in practice I am still seeing more database corruption than expected.

I will respond here after a while if I see changes.

@M66B
Copy link
Contributor Author

M66B commented Jan 7, 2023

I haven't seen any case of data loss anymore since removing this library from the app. That can't be coincidence.

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

No branches or pull requests

2 participants