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

Database Locked Error #757

Closed
danielPollackGitHub opened this issue Sep 19, 2018 · 5 comments
Closed

Database Locked Error #757

danielPollackGitHub opened this issue Sep 19, 2018 · 5 comments
Labels
Milestone

Comments

@danielPollackGitHub
Copy link

danielPollackGitHub commented Sep 19, 2018

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 TableExists()
{
try
{
var command =
$"SELECT count(tbl_name) FROM sqlite_master WHERE type = 'table' AND name = '{typeof(T).Name}'";
var count = await DbAsynchronousConnection.ExecuteScalarAsync(command).ConfigureAwait(false);

            return count > 0;
        }
        catch (SQLiteException sqLiteException)
        {
            throw;
            //todo: handle the exception
        }
    }
@mpapadis
Copy link

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.

@mpapadis
Copy link

I looked it a bit thorougher and I have found that it could also be a known bug: #740

@ClausElmann
Copy link

First time i works, but next time i open my app, I also get Database Locked.
no problems in 1.4.118 :-)

@praeclarum
Copy link
Owner

This should be fixed in the 1.6-beta. Please let me know if it is not!

@praeclarum praeclarum added the Bug label Jan 24, 2019
@praeclarum praeclarum added this to the v1.6 milestone Jan 24, 2019
@InquisitorJax
Copy link

InquisitorJax commented Jul 8, 2019

@praeclarum any updates on the 1.6 release ETA?
I'm seeing this lock issue on < iOS 12

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

No branches or pull requests

5 participants