-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After ignoring the database settings for a while the it came back to bite us when implementing the new extension paradigm. Sqlite started emitting database busy errors when a long running transaction was interrupted by some other write. This is because when you start a transaction in sqlite by default it occurs as DEFFERED. This means that sqlite does not try to lock th database until it comes across a write call. This means that some other thread could possibly come in and make a write call before the current transaction is finished. When this happens sqlite will see that the underlying data has changed and return an error for the open transaction. This is obviously bad because losing transactions is not a current situation we recover gracefully from. Instead it would be better if sqlite simply followed suite with other databases and just immediatley held a lock when opening a transaction. Which is actually able to be enabled by simply using the `BEGIN IMMEDIATE` statement when starting a transaction. But nothing is ever that simple. The library that we're using sqlx [does not yet support](launchbadge/sqlx#481) the ability to call `BEGIN IMMEDIATE` on transactions. Thus we had to come up with a hack. The hack being that when opening a transaction we immediately call a write to a dummy table as our first call. This should immediatley cause sqlite to hold a lock and more or less mimic the behavior of `BEGIN IMMEDIATE`.
- Loading branch information
1 parent
9eee9f7
commit c1aed51
Showing
39 changed files
with
413 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.