Skip to content
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

Getting a DatabaseException on startup: (database is locked (code 5 SQLITE_BUSY[5])) #429

Open
aletorrado opened this issue Sep 5, 2023 · 1 comment

Comments

@aletorrado
Copy link

🐛 Bug Report

Hi, I'm having a DatabaseException on the application's first load, when it tries to setup the database for the cache. The cache stays unusable for this first load, but the second time the application is opened it can work this out and then it will continue working every time.

This is a logcat output from Android:

09-05 16:18:26.154 19280 19371 I flutter : error DatabaseException(database is locked (code 5 SQLITE_BUSY[5])) sql 'BEGIN EXCLUSIVE' args [] during open, closing...
09-05 16:18:26.165 19280 19371 E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DatabaseException(database is locked (code 5 SQLITE_BUSY[5])) sql 'BEGIN EXCLUSIVE' args []
09-05 16:18:26.165 19280 19371 E flutter : #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:11)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #1      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:465)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #2      SqfliteDatabaseMixinExt.txnBeginTransaction (package:sqflite_common/src/database_mixin.dart:353)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #3      SqfliteDatabaseMixin.beginTransaction (package:sqflite_common/src/database_mixin.dart:719)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #4      SqfliteDatabaseMixinExt._txnTransaction (package:sqflite_common/src/database_mixin.dart:330)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #5      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #6      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:490)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #7      SqfliteDatabaseMixin.doOpen (package:sqflite_common/src/database_mixin.dart:939)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #8      SqfliteDatabaseOpenHelper.openDatabase (package:sqflite_common/src/database.dart:46)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #9      SqfliteDatabaseFactoryMixin.openDatabase.<anonymous closure> (package:sqflite_common/src/factory_mixin.dart:110)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #10     ReentrantLock.synchronized.<anonymous closure> (package:synchronized/src/reentrant_lock.dart:37)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #11     BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #12     CacheObjectProvider.open (package:flutter_cache_manager/src/storage/cache_info_repositories/cache_object_provider.dart:30)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>
09-05 16:18:26.165 19280 19371 E flutter : #13     CacheStore._getCacheDataFromDatabase (package:flutter_cache_manager/src/cache_store.dart:112)
09-05 16:18:26.165 19280 19371 E flutter : <asynchronous suspension>

At the moment I only tried this on Android, and I'm using version 3.3.1.

My first guess is that some other library may be using Sqlite at the same time, or some other thing like that, but anyways that doesn't seems to be a good reason to crash. Is this issue known?

Thank you

@Z6P0
Copy link

Z6P0 commented Dec 10, 2024

Same here:

I/flutter (18492): error DatabaseException(database is locked (code 5 SQLITE_BUSY)) sql 'BEGIN EXCLUSIVE' args [] during open, closing...
E/flutter (18492): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DatabaseException(database is locked (code 5 SQLITE_BUSY)) sql 'BEGIN EXCLUSIVE' args []
E/flutter (18492): #0      wrapDatabaseException (package:sqflite_platform_interface/src/platform_exception.dart:12:7)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #1      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:485:16)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #2      SqfliteDatabaseMixinExt.txnBeginTransaction (package:sqflite_common/src/database_mixin.dart:358:20)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #3      SqfliteDatabaseMixin.beginTransaction (package:sqflite_common/src/database_mixin.dart:746:5)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #4      SqfliteDatabaseMixinExt._txnTransaction (package:sqflite_common/src/database_mixin.dart:333:13)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #5      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:36:16)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #6      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:517:14)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #7      SqfliteDatabaseMixin.doOpen (package:sqflite_common/src/database_mixin.dart:999:13)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #8      SqfliteDatabaseOpenHelper.openDatabase (package:sqflite_common/src/database.dart:46:7)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #9      SqfliteDatabaseFactoryMixin.openDatabase.<anonymous closure> (package:sqflite_common/src/factory_mixin.dart:112:18)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #10     ReentrantLock.synchronized.<anonymous closure> (package:synchronized/src/reentrant_lock.dart:37:18)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #11     BasicLock.synchronized (package:synchronized/src/basic_lock.dart:36:16)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #12     CacheObjectProvider.open (package:flutter_cache_manager/src/storage/cache_info_repositories/cache_object_provider.dart:30:10)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #13     new CacheStore.<anonymous closure> (package:flutter_cache_manager/src/cache_store.dart:34:56)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #14     CacheStore._getCacheDataFromDatabase (package:flutter_cache_manager/src/cache_store.dart:112:22)
E/flutter (18492): <asynchronous suspension>
E/flutter (18492): #15     CacheStore.retrieveCacheData.<anonymous closure> (package:flutter_cache_manager/src/cache_store.dart:73:43)
E/flutter (18492): <asynchronous suspension>

This is crashing my app in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants