Skip to content

io.objectbox.exception.FileCorruptException: Corrupt DB, min key size violated: 0 #1143

Description

@linge123

hello in my app always

Basic info (please complete the following information):
ObjectBox version : :3.5.1
Reproducibility: occurred once only
Devices: android

init boxStore code:
BoxStoreBuilder storeBuilder = MyObjectBox.builder()
.validateOnOpen(ValidateOnOpenMode.WithLeaves) // Additional DB page validation
.validateOnOpenPageLimit(20)
.androidContext(context.getApplicationContext())

queryData code:
getBox().query().equal(Db_.userId, "4229047", QueryBuilder.StringOrder.CASE_INSENSITIVE).build().find();

Logs, stack traces:
io.objectbox.exception.FileCorruptException: Corrupt DB, min key size violated: 0
at io.objectbox.query.Query.nativeFind(Native Method)
at io.objectbox.query.Query.lambda$find$2$io-objectbox-query-Query(Query.java:252)
at io.objectbox.query.Query$$ExternalSyntheticLambda4.call(Unknown Source:2)
at io.objectbox.BoxStore.callInReadTx(BoxStore.java:940)
at io.objectbox.BoxStore.callInReadTxWithRetry(BoxStore.java:886)
at io.objectbox.query.Query.callInReadTx(Query.java:368)
at io.objectbox.query.Query.find(Query.java:251)

image

Activity

  1. greenrobot commented on Jul 23, 2023

    @greenrobot
    Member

    Reproducibility: occurred once only

    That's a little problematic to work with because the stacktrace doesn't help us in this case.

    If you see some way to reproduce, please let us know. Otherwise, a next upcoming version will provide validation for this error type, which might be helpful.

    Edit: See also related #1090.

  2. mobileAiDev commented on Aug 14, 2023

    @mobileAiDev

    i get this error also,in my case ,i found another problem,some data can't been query by isNull, after that i get this error in bugly

  3. mobileAiDev commented on Aug 14, 2023

    @mobileAiDev

    here is the stackTrace,user already unistall the app,so i can't provide more infomation for this
    #2 main

    io.objectbox.exception.FileCorruptException

    Corrupt DB, min key size violated: 0

    io.objectbox.query.Query.nativeFind(Native Method)
    io.objectbox.query.Query.lambda$find$2$io-objectbox-query-Query(Query.java:252)
    io.objectbox.query.Query$$ExternalSyntheticLambda6.call(Unknown Source:2)
    io.objectbox.BoxStore.callInReadTx(BoxStore.java:940)
    io.objectbox.BoxStore.callInReadTxWithRetry(BoxStore.java:886)
    io.objectbox.query.Query.callInReadTx(Query.java:368)
    io.objectbox.query.Query.find(Query.java:251)

  4. added this to the 3.6.1 milestone on Aug 23, 2023
  5. greenrobot-team commented on Aug 23, 2023

    @greenrobot-team
    Member

    We have released version 3.7.0 which contains a new validation option to help diagnose this issue.

    A new key/value validation option validateOnOpenKv() is available on MyObjectBox.builder(). If enabled, the build() call will throw a FileCorruptException if corruption is detected with details on which key/value is affected in the exception message.

    This can be used if the above exception is thrown to re-open the store with additional validation to get more details:

    try {
        boxStore = storeBuilder.build();
    } catch (FileCorruptException e) {
        try {
            boxStore = MyObjectBox.builder()
                    .androidContext(context.getApplicationContext())
                    .validateOnOpenKv()
                    .build();
        } catch (FileCorruptException ce) {
            // TODO Report the exception message, for example:
            // KV validation failed; key is empty (KV pair number: 1, key size: 0, data size: 112)
        }
    }
    
  6. linge123 commented on Aug 24, 2023

    @linge123
    Author

    We have released version 3.7.0 which contains a new validation option to help diagnose this issue.

    A new key/value validation option validateOnOpenKv() is available on MyObjectBox.builder(). If enabled, the build() call will throw a FileCorruptException if corruption is detected with details on which key/value is affected in the exception message.

    This can be used if the above exception is thrown to re-open the store with additional validation to get more details:

    try {
        boxStore = storeBuilder.build();
    } catch (FileCorruptException e) {
        try {
            boxStore = MyObjectBox.builder()
                    .androidContext(context.getApplicationContext())
                    .validateOnOpenKv()
                    .build();
        } catch (FileCorruptException ce) {
            // TODO Report the exception message, for example:
            // KV validation failed; key is empty (KV pair number: 1, key size: 0, data size: 112)
        }
    }
    

    FileCorruptException:

    io.objectbox.exception.FileCorruptException: KV validation failed; key is empty (KV pair number: 40753, key size: 0, data size: 3145)

  7. greenrobot-team commented on Aug 28, 2023

    @greenrobot-team
    Member

    @linge123 Thanks for this!

    If possible, can you send use the corrupted database file? (We have some example code on how to ask users to do this for a production app.)

    Also to everyone, would it be helpful if ObjectBox included a repair mode that would delete corrupted keys and values (basically affected objects)?

  8. linge123 commented on Aug 28, 2023

    @linge123
    Author

    Add a repair mode, that would be great。

    The database contains user private information, which is best not to do so

  9. mobileAiDev commented on Sep 12, 2023

    @mobileAiDev

    Add a repair mode, that would be great。

    The database contains user private information, which is best not to do so

    how many data when crash happens ? i guess it may assosiate with data size , in my case it was about 50W data in one table

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions