Skip to content

when app restarted,if the db file is corrupted,BoxStore nativeCreate function will crash has no throwable! #865

Closed

Description

@lakehubo

hello,i need a throwable when the db file is corrupted that i can delete the db file and recreate it!but now there is not throwable can catch when the boxstore build,and the app will crash all the time!
andriod 8.1

Activity

  1. greenrobot commented on Jun 10, 2020

    @greenrobot
    Member

    Do you have any information on the crash? E.g. start by check the logs.

    Also, do you have any info on how the DB file got corrupted?

    PS.: We're not aware of any issue resulting in a crash/corruption, so I'm very curious...

  2. lakehubo commented on Jun 11, 2020

    @lakehubo
    Author

    there is the error log,i have the corrupted db files if you need.
    my device was runing all the time with power adapter and no battery,so if the power shutdown,there will can make the db file corrupted;

    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'Xiaomi/cepheus/cepheus:10/QKQ1.190825.002/V11.0.9.0.QFACNXM:user/release-keys'
    Revision: '0'
    ABI: 'arm'
    Timestamp: 2020-06-11 09:42:52+0800
    pid: 26202, tid: 26202, name: m.nbicc.airobot  >>> com.nbicc.airobot <<<
    uid: 12054
    signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0xe053b00a
         r0  e053b000  r1  0000000a  r2  00000001  r3  00000001
         r4  c1d03c80  r5  00000220  r6  00220000  r7  ffd87338
         r8  00000000  r9  d2f8a950  r10 d2592880  r11 e0531000
         ip  ffd872a8  sp  ffd872c0  lr  c17adbab  pc  c17aad14
    
    backtrace:
           #00 pc 0008dd14  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
          #01 pc 0009048d  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #02 pc 0008ce4d  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #03 pc 0008c657  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #04 pc 0008d4e1  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
          #05 pc 000907a7  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #06 pc 0008d17b  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
          #07 pc 0008b451  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
          #08 pc 00055937  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #09 pc 00050245  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #10 pc 00081853  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
          #11 pc 00083107  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #12 pc 00082f5d  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
          #13 pc 00046d25  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
           #14 pc 0001b775  /data/app/com.nbicc.airobot-Qc5vMmxcTWhmMNleCfJ7QQ==/base.apk!libobjectbox-jni.so (offset 0x688000) (Java_io_objectbox_BoxStore_nativeCreate+100) (BuildId: 74faefff0162633e5562d24d11836e36cacd1204)
    
  3. greenrobot commented on Jun 11, 2020

    @greenrobot
    Member

    Thank you.

    And yes, the DB files could be very interesting to check. Can you attach them or do you prefer to send, e.g. by mail?

    Which ObjectBox version were you running when the issue occurred?

    PS.: ObjectBox builds upon mechanisms that should never corrupt any db files. If you turn off the device in the midst of writing a new transaction, it will have a consistent data view of the state before the (aborted) transaction.

  4. lakehubo commented on Jun 11, 2020

    @lakehubo
    Author
  5. greenrobot commented on Jun 11, 2020

    @greenrobot
    Member

    Thanks for the files! I'm seeing a "No DB catalog present" message when I try to open the db file. This tells me that some very basic meta information seems unavailable in the file. Can you completely rule out that this file was not overwritten by something else? Are you 100% sure?

  6. lakehubo commented on Jun 11, 2020

    @lakehubo
    Author

    this db file is copy from the device,and i have never edit it.and the device running all the time,somtimes that will maybe abnormal shutdown.i guess that the reason of db corrupted probability.

  7. lakehubo commented on Jun 11, 2020

    @lakehubo
    Author

    Can you thorw these error meesage?that i can delete the corrupted db file.
    Thanks so much.

  8. greenrobot commented on Jun 11, 2020

    @greenrobot
    Member

    I'll investigate...

    Btw, in the given file, I see 8 entries representing entities, but no meta info...

    The thing is even an abnormal shutdown should never result in this file. Maybe if the OS / file system does something wrong (e.g. breaking fsync semantics). Did you find a way to reproduce this? Is this limited to a specific device?

  9. lakehubo commented on Jun 12, 2020

    @lakehubo
    Author

    it happened small chance and fatal, i have no way to reproduce this.but it happend on a specified device,Rk3399 development board with android8.1.

  10. RRRaymon commented on Jun 17, 2020

    @RRRaymon

    I encountered the same problem.
    I tried to write a loop to add data to the objectbox all the time, and then power off my device, there is a chance to reproduce the situation of db corrupted. The specific performance is that the data can be read from the objectbox, but it crashes when I write

  11. greenrobot commented on Jun 18, 2020

    @greenrobot
    Member

    @RRRaymon can you share the involved device and Android version? Also, was it on internal storage? You did not have I/O errors otherwise on that disk?

  12. RRRaymon commented on Jun 19, 2020

    @RRRaymon

    Android version:8.1
    involved device is Sunrise x1600(Produced by Horizon)

    objectbox‘s db file address is default,in /data/data/.../files/objectbox/objectbox/

    You can check the corrupted db file I tested。
    the testing process is as mentioned above,the difference is that some entities will crash when I execute findAll, not just add

    objectbox.zip

  13. hzqhzqhzq1 commented on Jun 30, 2020

    @hzqhzqhzq1

    i hava the same problem,the same device producted by Horizon

  14. greenrobot commented on Jul 1, 2020

    @greenrobot
    Member

    It might be worth contacting the support of the device manufactures; especially Horizon. This was never reported before, and given the reports lately, it seems likely that something is wrong with the file system on those devices. Do you have a chance to report this (or have a link)?

  15. greenrobot commented on Jul 28, 2020

    @greenrobot
    Member

    Quick update: we'll release new new version addressing this very soon. It should detect some common cases. Details will follow in this thread.

  16. added this to the 2.7.0 milestone on Jul 29, 2020
  17. greenrobot commented on Jul 30, 2020

    @greenrobot
    Member

    Version 2.7.0 added some additional checks to detect inconsistencies that can be caused by broken file systems like it seems the case here (e.g. fsync'ed data is out-of-order). A minimal check is now done always, causing the new FileCorruptException if it fails. There's more related features, e.g. validateOnOpen settings in BoxStoreBuilder, validate() in BoxStore. There's also a new BoxStoreBuilder option to use the previous snapshot, which may restore data. For now best check the JavaDocs in the sources.

    Please let us know if this is helpful and catches most (all?) error caused on that devices... Thank you.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions