Merge pull request #4782 from bendk/places-db-locked
Use BEGIN IMMEDIATE in `open_database`
This commit is contained in:
Коммит
d5c490946e
|
@ -18,3 +18,10 @@ Use the template below to make assigning a version number during the release cut
|
|||
- Description of the change with a link to the pull request ([#0000](https://github.com/mozilla/application-services/pull/0000))
|
||||
|
||||
-->
|
||||
|
||||
## Places
|
||||
|
||||
### What's Changed
|
||||
- The database initialization code now uses BEGIN IMMIDIATE to start a
|
||||
transaction. This will hopefully prevent `database is locked` errors when
|
||||
opening a sync connection.
|
||||
|
|
|
@ -28,7 +28,10 @@
|
|||
/// See the autofill DB code for an example.
|
||||
///
|
||||
use crate::ConnExt;
|
||||
use rusqlite::{Connection, Error as RusqliteError, ErrorCode, OpenFlags, Transaction, NO_PARAMS};
|
||||
use rusqlite::{
|
||||
Connection, Error as RusqliteError, ErrorCode, OpenFlags, Transaction, TransactionBehavior,
|
||||
NO_PARAMS,
|
||||
};
|
||||
use std::path::Path;
|
||||
use thiserror::Error;
|
||||
|
||||
|
@ -113,7 +116,7 @@ fn do_open_database_with_flags<CI: ConnectionInitializer, P: AsRef<Path>>(
|
|||
connection_initializer.prepare(&conn)?;
|
||||
|
||||
if open_flags.contains(OpenFlags::SQLITE_OPEN_READ_WRITE) {
|
||||
let tx = conn.transaction()?;
|
||||
let tx = conn.transaction_with_behavior(TransactionBehavior::Immediate)?;
|
||||
if run_init {
|
||||
log::debug!("{}: initializing new database", CI::NAME);
|
||||
connection_initializer.init(&tx)?;
|
||||
|
|
Загрузка…
Ссылка в новой задаче