Skip to content

Android- SQLITE_IOERR_GETTEMPPATH 6410 on very complex queries #876

Description

@knaeckeKami

I'm running into an issue that occurs with complex queries on big-ish (~50mb) databases on Android using the ffi/sqlite3 library.

When running the query, I get an error code 6410 (SQLITE_IOERR_GETTEMPPATH):

SqliteException(6410): disk I/O error, disk I/O error (code 6410)
/flutter (17699): #0      throwException (package:sqlite3/src/impl/exception.dart:32:3)
I/flutter (17699): #1      PreparedStatementImpl.select (package:sqlite3/src/impl/statement.dart:59:7)
I/flutter (17699): #2      _VmDelegate.runSelect (package:moor/src/ffi/vm_database.dart:128:25)
I/flutter (17699): #3      _ExecutorWithQueryDelegate.runSelect.<anonymous closure> (package:moor/src/runtime/executor/helpers/engines.dart:41:19)
I/flutter (17699): #4      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:32:26)
I/flutter (17699): #5      _ExecutorWithQueryDelegate._synchronized (package:moor/src/runtime/executor/helpers/engines.dart:22:26)
I/flutter (17699): #6      _ExecutorWithQueryDelegate.runSelect (package:moor/src/runtime/executor/helpers/engines.dart:39:26)
I/flutter (17699): #7      _MoorServer._runQuery (package:moor/src/runtime/isolate/server.dart:89:25)
I/flutter (17699): <asynchronous suspension>
I/flutter (17699): #8      _MoorServer._handleRequest (package:moor/src/runtime/isolate/server.dart:57:14)
I/flutter (17699): #9      IsolateCommunication.setRequestHandler.<anonymous closure> (package:moor/src/runtime/isolate/communication.dart:163:31)
I/flutter (17699): #17     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)

From what I researched, this seems to happen that the intermediate results for SQLite were too big to handle them in-memory, but SQLite could not find a temporary directory to store the result.

Luckily, I found a fix/workaround:
According to https://stackoverflow.com/questions/44766917/sql-logic-error-only-when-querying-on-android ,
this can be fixed by setting a pragma:

if(Platform.isAndroid){
   final cachebase =  (await getTemporaryDirectory()).path;
   db.customStatement("PRAGMA temp_store_directory = '$cachebase';");
}

I'm a little bit concerned though, since this pragma is deprecated according to https://www.sqlite.org/pragma.html#pragma_temp_store_directory

I'm just wondering if we can do anything to have this 'just work' for other users?
Where do you get the sqlite library, that is shipped with sqlite3_flutter_libs, from? Do you compile it yourself? If yes, then maybe it is possible to set a compiler flag so that this does not happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions