Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dae6d370 authored by Paul Westbrook's avatar Paul Westbrook
Browse files

Revert "turn off sqlite WAL until bugs bug:3024421 and bug:3353077 are fixed"

This reverts commit d67dbeeb.

This reenables WAL in the framework.  We are tracking down the cause of
the problems with WAL
parent 2e10374d
Loading
Loading
Loading
Loading
+44 −47
Original line number Original line Diff line number Diff line
@@ -2354,39 +2354,37 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @return true if write-ahead-logging is set. false otherwise
     * @return true if write-ahead-logging is set. false otherwise
     */
     */
    public boolean enableWriteAheadLogging() {
    public boolean enableWriteAheadLogging() {
        // turn off WAL until lockingprotocolerror bug and diskIO bug are fixed
        // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases.
        if (isReadOnly()) {
            return false;
        }
        // acquire lock - no that no other thread is enabling WAL at the same time
        lock();
        try {
            if (mConnectionPool != null) {
                // already enabled
                return true;
            }
            if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) {
                Log.i(TAG, "can't enable WAL for memory databases.");
                return false;
            }

            // make sure this database has NO attached databases because sqlite's write-ahead-logging
            // doesn't work for databases with attached databases
            if (mHasAttachedDbs) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG,
                            "this database: " + mPath + " has attached databases. can't  enable WAL.");
                }
                return false;
                return false;
//        // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases.
            }
//        if (isReadOnly()) {
            mConnectionPool = new DatabaseConnectionPool(this);
//            return false;
            setJournalMode(mPath, "WAL");
//        }
            return true;
//        // acquire lock - no that no other thread is enabling WAL at the same time
        } finally {
//        lock();
            unlock();
//        try {
        }
//            if (mConnectionPool != null) {
//                // already enabled
//                return true;
//            }
//            if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) {
//                Log.i(TAG, "can't enable WAL for memory databases.");
//                return false;
//            }
//
//            // make sure this database has NO attached databases because sqlite's write-ahead-logging
//            // doesn't work for databases with attached databases
//            if (mHasAttachedDbs) {
//                if (Log.isLoggable(TAG, Log.DEBUG)) {
//                    Log.d(TAG,
//                            "this database: " + mPath + " has attached databases. can't  enable WAL.");
//                }
//                return false;
//            }
//            mConnectionPool = new DatabaseConnectionPool(this);
//            setJournalMode(mPath, "WAL");
//            return true;
//        } finally {
//            unlock();
//        }
    }
    }


    /**
    /**
@@ -2394,20 +2392,19 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @hide
     * @hide
     */
     */
    public void disableWriteAheadLogging() {
    public void disableWriteAheadLogging() {
        return;
        // grab database lock so that writeAheadLogging is not disabled from 2 different threads
//        // grab database lock so that writeAheadLogging is not disabled from 2 different threads
        // at the same time
//        // at the same time
        lock();
//        lock();
        try {
//        try {
            if (mConnectionPool == null) {
//            if (mConnectionPool == null) {
                return; // already disabled
//                return; // already disabled
            }
//            }
            mConnectionPool.close();
//            mConnectionPool.close();
            setJournalMode(mPath, "TRUNCATE");
//            setJournalMode(mPath, "TRUNCATE");
            mConnectionPool = null;
//            mConnectionPool = null;
        } finally {
//        } finally {
            unlock();
//            unlock();
        }
//        }
    }
    }


    /* package */ SQLiteDatabase getDatabaseHandle(String sql) {
    /* package */ SQLiteDatabase getDatabaseHandle(String sql) {