Skip to content

Unexpected error: "migrate database: sqlite: step: database is locked" #96

Discussion options

You must be logged in to vote

@zombiezen I've discovered a few things, with some good news.

First, the issue appears to be fixable in sqlitemigration ensureAppID function. The function opens a deferred transaction that will later be upgraded to a write transaction. At the point of upgrading to a write transaction, if the database is locked, SQLite will fail immediately with SQLITE_BUSY [1] [2] and the busy timeout will have no effect, causing the pool to fail to start.

If ensureAppID is switched use an immediate transaction, that tells SQLite this is a write transaction. SQLite will attempt to lock the database immediately. If a lock cannot be acquired, the busy timeout is used allowing the transaction to wait until i…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bradenrayhorn
Comment options

@bradenrayhorn
Comment options

@bradenrayhorn
Comment options

Answer selected by bradenrayhorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants