realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.47k stars 1.75k forks source link

Unrecoverable error. msync() failed #5541

Closed ajax1533 closed 7 years ago

ajax1533 commented 7 years ago

Hello folks,

We have an android device running a custom build of Android 2.3.3. We recently pulled in realm to manage data in our app and we noticed that in few prod devices, we saw our app crash due to the following exceptions.

This exception was random and we could not reproduce it in our test environment. Also, this was reported by very few devices which we were working fine otherwise.

We store only limited data in realm and we checked to confirm that there are no space constraints. Also, we made sure that we do not write to realm on the main thread.

Unrecoverable error. msync() failed: I/O error in /home/cc/repo/realm/release/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 295

Unrecoverable error. msync() failed: Read-only file system in /home/cc/repo/realm/release/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 295

We would love to know if there is a deeper issue that we might have missed. This is the first time I am making a bug on Github. Let me know in case I missed anything. thanks for your time!

Expected Results

Realm Save on background thread should work in all devices.

Actual Results

io.realm.exceptions.RealmError io.realm.internal.SharedRealm.nativeCommitTransaction(Native Method) io.realm.internal.SharedRealm.commitTransaction(SharedRealm.java:262) io.realm.BaseRealm.commitTransaction(BaseRealm.java:359) io.realm.Realm.commitTransaction(Realm.java:132) io.realm.Realm.executeTransaction(Realm.java:1404)

Steps & Code to Reproduce

We have not been able to reproduce this issue in our test devices. we noticed this exception while analyzing crashes on production devices.

Code Sample

Unfortunately, I cannot share the complete code, but this is how we normally save a realm object.


> Realm realm = Realm.getDefaultInstance();
> realm.executeTransaction(realm1 -> realm1.copyToRealmOrUpdate(object));
> realm.close();

Version of Realm and tooling

Realm version(s): ? Realm gradle plugin 3.5

Android Studio version: 3.0

Which Android version and device: 2.3.3 Gingerbread | custom android device

beeender commented 7 years ago

We call msync with MS_SYNC to flush data to the disk. From the exception message, it seems the msync system call failed with EIO.

Since it is the first time we get this kind of crash reported and it was happening on a custom build 2.3.3, i doubt there is a bug with the msync call with the that device (or there is a hardware issue with the device's flash). I think there is not too much we can do about it.

ajax1533 commented 7 years ago

Thanks @beeender ! Gd to know. We think that its a hardware issue as well.