mirror of
https://github.com/lldap/lldap.git
synced 2024-11-24 08:45:08 +00:00
server: Only use a single connection with SQlite
Several writer connections can lock the DB and cause other inserts to fail. A single connection should be enough given the usual workloads
This commit is contained in:
parent
35fe521cbe
commit
143eb70bee
2 changed files with 12 additions and 1 deletions
|
@ -17,6 +17,12 @@ impl From<&str> for DatabaseUrl {
|
|||
}
|
||||
}
|
||||
|
||||
impl DatabaseUrl {
|
||||
pub fn db_type(&self) -> &str {
|
||||
self.0.scheme()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for DatabaseUrl {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if self.0.password().is_some() {
|
||||
|
|
|
@ -82,9 +82,14 @@ async fn ensure_group_exists(handler: &SqlBackendHandler, group_name: &str) -> R
|
|||
|
||||
async fn setup_sql_tables(database_url: &DatabaseUrl) -> Result<DatabaseConnection> {
|
||||
let sql_pool = {
|
||||
let num_connections = if database_url.db_type() == "sqlite" {
|
||||
1
|
||||
} else {
|
||||
5
|
||||
};
|
||||
let mut sql_opt = sea_orm::ConnectOptions::new(database_url.to_string());
|
||||
sql_opt
|
||||
.max_connections(5)
|
||||
.max_connections(num_connections)
|
||||
.sqlx_logging(true)
|
||||
.sqlx_logging_level(log::LevelFilter::Debug);
|
||||
Database::connect(sql_opt).await?
|
||||
|
|
Loading…
Reference in a new issue