mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Fix database is locked errors
This commit is contained in:
parent
304146713d
commit
f58597f574
|
|
@ -5,6 +5,7 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -25,6 +26,17 @@ func Open(dbProperties *config.DatabaseOptions, writer Writer) (*sql.DB, error)
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("ParseFileURI: %w", err)
|
||||
}
|
||||
|
||||
// add query parameters to the dsn
|
||||
if strings.Contains(dsn, "?") {
|
||||
dsn += "&"
|
||||
} else {
|
||||
dsn += "?"
|
||||
}
|
||||
|
||||
// wait some time before erroring if the db is locked
|
||||
// https://gitlab.com/cznic/sqlite/-/issues/106#note_1058094993
|
||||
dsn += "_pragma=busy_timeout%3d10000"
|
||||
case dbProperties.ConnectionString.IsPostgres():
|
||||
driverName = "postgres"
|
||||
dsn = string(dbProperties.ConnectionString)
|
||||
|
|
|
|||
Loading…
Reference in a new issue