I have upgraded from 1.4.118 to 1.5.231 and whenever I try to execute a scalar on an asynchronous connection, I receive an error that the database is locked. I had do downgrade to 1.4.118 and the issue is no longer present. What changed? I'm using this for a Xamarin forms project in conjunction with MVVMCross 6.2. Here is the simple method I call:
public async Task
{
try
{
var command =
$"SELECT count(tbl_name) FROM sqlite_master WHERE type = 'table' AND name = '{typeof(T).Name}'";
var count = await DbAsynchronousConnection.ExecuteScalarAsync
return count > 0;
}
catch (SQLiteException sqLiteException)
{
throw;
//todo: handle the exception
}
}
What is this DbAsynchronousConnection you are using?
Try creating a new instance of a SQLiteAsyncConnection and using that for the ExecuteScalarAsync command. I think you use a single instance of SQLiteAsyncConnection for multiple queries and that is the source of your problems.
Moreover, check if you have storage permission acquired before running commands on the database.
I looked it a bit thorougher and I have found that it could also be a known bug: #740
First time i works, but next time i open my app, I also get Database Locked.
no problems in 1.4.118 :-)
This should be fixed in the 1.6-beta. Please let me know if it is not!
@praeclarum any updates on the 1.6 release ETA?
I'm seeing this lock issue on < iOS 12