Baseflow / flutter_cache_manager

Generic cache manager for flutter
https://baseflow.com
MIT License
739 stars 426 forks source link

ios sqflite DatabaseException "disk I/O error" #337

Open luckv opened 2 years ago

luckv commented 2 years ago

🐛 Bug Report

Stacktrace:

DatabaseException(Error Domain=FMDatabase Code=6922 "disk I/O error" UserInfo={NSLocalizedDescription=disk I/O error}) sql 'DELETE FROM cacheObject WHERE _id IN ()' args []}. Error thrown null.
Non-fatal Exception: FlutterError
0  ???                            0x0 wrapDatabaseException + 11 (exception_impl.dart:11)
1  ???                            0x0 <fn> + 420 (database_mixin.dart:420)
2  ???                            0x0 synchronized + 33 (basic_lock.dart:33)
3  ???                            0x0 txnSynchronized + 346 (database_mixin.dart:346)
4  ???                            0x0 emptyCache + 149 (cache_store.dart:149)
5  ???                            0x0 <fn> (dart:async)
6  ???                            0x0 doLogout + 535 (loginbloc.dart:535)
7  ???                            0x0 <fn> + 238 (bloc.dart:238)

Happened only to one user, but 8 times in a row, in an iOS released app. I add a comment to the same error in the sqflite repository

Reproduction steps

Seems that erasing the cache this problem arose. But I wasn't able to reproduce. From the analyics log I can say that happened when the user logged out, in that moment I erase the cache calling CacheManager.emptyCache()

Configuration

Output of flutter --version

Package version: 2.1.2. I know it's a major release behind, but it doesn't seem this problem has been encountered searching for this issue in the repository, anyway, I'll upgrade the package and proceed to release a new version of the app.

Platform:

luckv commented 2 years ago

The exact same error happened again with flutter_cache_manager 3.1.2!

Two times in a row for the same user. Here below the stacktraces from crashlytics.

The first time the exception was launched from my code:

DatabaseException(Error Domain=FMDatabase Code=6922 "disk I/O error" UserInfo={NSLocalizedDescription=disk I/O error}) sql 'DELETE FROM cacheObject WHERE _id IN ()' args []}. Error thrown null.
Non-fatal Exception: FlutterError
0  ???                            0x0 (null).wrapDatabaseException + 11 (exception_impl.dart:11)
1  ???                            0x0 SqfliteDatabaseMixin.txnRawUpdate.<fn> + 420 (database_mixin.dart:420)
2  ???                            0x0 BasicLock.synchronized + 33 (basic_lock.dart:33)
3  ???                            0x0 SqfliteDatabaseMixin.txnSynchronized + 346 (database_mixin.dart:346)
4  ???                            0x0 CacheStore.emptyCache + 158 (cache_store.dart:158)
5  ???                            0x0 Future.wait.<fn> (dart:async)
6  ???                            0x0 LoginBloc.doLogout + 570 (login_bloc.dart:570). <-- This is my code, when the 

One second after, the same exception is thrown from code I didn't call:

DatabaseException(Error Domain=FMDatabase Code=6922 "disk I/O error" UserInfo={NSLocalizedDescription=disk I/O error}) sql 'DELETE FROM cacheObject WHERE _id IN ()' args []}. Error thrown null.
Non-fatal Exception: FlutterError
0  ???                            0x0 (null).wrapDatabaseException + 11 (exception_impl.dart:11)
1  ???                            0x0 SqfliteDatabaseMixin.txnRawUpdate.<fn> + 420 (database_mixin.dart:420)
2  ???                            0x0 BasicLock.synchronized + 33 (basic_lock.dart:33)
3  ???                            0x0 SqfliteDatabaseMixin.txnSynchronized + 346 (database_mixin.dart:346)
4  ???                            0x0 CacheStore._cleanupCache + 148 (cache_store.dart:148)

Cause

The same cause of the stacktrace in the previous comment. Seems that erasing the cache this problem arose.

I thought that may be this was a problem of the version 2.x of the plugin. But it's not this case. A guy of the sqflite repository tell that is not a problem with their library. I think that is caused by some wrong query generation.

Configuration

Output of flutter --version

Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 18116933e7 (3 months ago) • 2021-10-15 10:46:35 -0700 Engine • revision d3ea636dc5 Tools • Dart 2.14.4

Package version

3.1.2

Platform

iOS: 15.2.0