Skip to content

Connecting to a locked database, message that looks like an error #197

Closed

Description

@gaborcsardi

Prints this:

Error in rsqlite_send_query(conn@ptr, statement) : database is locked

which is very misleading, because it does create the valid connection, and this is not really an error, just a message. I am not sure where it is coming from, maybe from the C client and then it is hard to fix. To reproduce, just create a DB from one process (or the shell), and lock it, then connect from another process:

❯ sqlite3 /tmp/xxx
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> BEGIN EXCLUSIVE;
library(DBI)
con <- dbConnect(RSQLite::SQLite(), "/tmp/xxx")
#> Error in rsqlite_send_query(conn@ptr, statement) : database is locked
con
#> <SQLiteConnection>
#>  Path: /private/tmp/xxx
#>  Extensions: TRUE

Activity

  1. krlmlr commented on Jan 9, 2017

    @krlmlr
    Member

    It's the try() calls in dbConnect(), a message that setting PRAGMA synchronous has failed should be printed instead. You can turn off the misleading message by asking dbConnect(synchronous = NULL) .

  2. gaborcsardi commented on Jan 9, 2017

    @gaborcsardi
    ContributorAuthor

    Thanks!

  3. gaborcsardi commented on Jan 9, 2017

    @gaborcsardi
    ContributorAuthor

    Btw. does this have any consequences, I mean, if setting the PRAGMA fails?

  4. krlmlr commented on Jan 9, 2017

    @krlmlr
    Member

    Writing is a tad slower. I wonder why setting the PRAGMA fails when the DB is locked; it's not documented whether the PRAGMA setting is persistent or connection-local.

  5. gaborcsardi commented on Jan 9, 2017

    @gaborcsardi
    ContributorAuthor

    I know some pragmas belong to the connection, e.g. the busy timeout.

    But it seems that this one belongs to the database.

  6. krlmlr commented on Jan 9, 2017

    @krlmlr
    Member

    That would mean that setting it for every connection is plain wrong. Do you have a reference?

  7. gaborcsardi commented on Jan 9, 2017

    @gaborcsardi
    ContributorAuthor

    Yeah, I take it back. It does belong to the connection.

  8. gaborcsardi commented on Jan 9, 2017

    @gaborcsardi
    ContributorAuthor

    I don't have a reference, just saw that it reverts back to the default if you close the connection that set it.

  9. gaborcsardi commented on Jan 9, 2017

    @gaborcsardi
    ContributorAuthor

    Anyway, it seems that RSQLite cannot really do much about this, except maybe give a better message.

  10. gaborcsardi commented on Apr 4, 2017

    @gaborcsardi
    ContributorAuthor

    👍

  11. added a commit that references this issue on Apr 28, 2017
  12. added a commit that references this issue on Jun 19, 2017
  13. Hamedhm commented on Jun 27, 2019

    @Hamedhm

    Hi

    I get the same error message, Couldn't set synchronous mode: database is locked

    I am using a cluster of several thousands of core working out the SQLite. I am wondering where the Serialized option is available on RSQLite? See https://www.sqlite.org/threadsafe.html

  14. krlmlr commented on Jul 7, 2019

    @krlmlr
    Member

    I'm not sure if thread safety is an issue -- R is single-threaded. Either way, can you please open a new issue?

  15. github-actions commented on Dec 7, 2020

    @github-actions
    Contributor

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

  16. locked and limited conversation to collaborators on Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions