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

ForestDBViewStore eats exception when closeIndex() fails #1556

Open
mvysny opened this Issue Jan 16, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@mvysny

mvysny commented Jan 16, 2017

The closeIndex() code (disassembled) is as follows:

    private void closeIndex() {
        for(int i = 0; i < 100 && this._view != null; ++i) {
            try {
                this._view.close();
                this._view = null;
            } catch (ForestException var5) {
                Log.w(TAG, "Failed to close Index: [%s] [%s]", new Object[]{this._view, Thread.currentThread().getName()});

                try {
                    Thread.sleep(100L);
                } catch (Exception var4) {
                    ;
                }
            }
        }

    }

The exception is silently eaten - sure, it is thrown by a native code but at least the message would be interesting?
Also, it seems that the view ultimately fails to close but the program continues after 10 seconds - is this intentional? Would the failure to close the view not corrupt the database?
This issue relates to #1528

@hideki

This comment has been minimized.

hideki commented Jan 16, 2017

Hi @mvysny,

Usually View.close() throws ForestException if View is used by other thread. It keeps retrying maximum 100 times. This is intentional. The database is not corrupted for this case.
https://github.com/couchbaselabs/couchbase-lite-java-forestdb/blob/9f9efbe85c0d667b212fb92290da8c2c6c7fc81e/src/main/java/com/couchbase/lite/store/ForestDBViewStore.java#L619

#1528 Deleting DB file fails because the DB file is still in used. We need to check before deleting DB if DB is in use.

@hideki hideki added the forestdb label Jan 16, 2017

@hideki

This comment has been minimized.

hideki commented Jan 16, 2017

Note:

We might need to change closeIndex() to return a boolean or to throw Exception if the method fails.

@hideki hideki added the P2: medium label Jan 20, 2017

@djpongh djpongh added the icebox label Jan 20, 2017

@djpongh djpongh added this to the 1.5.0 milestone Nov 28, 2017

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