summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-06-15 04:51:17 +0200
committerGitHub <noreply@github.com>2017-06-15 04:51:17 +0200
commitbf48c8ebdd3975d1090115a9106069796c67a6da (patch)
tree3c9d34ea632511d339e8cac16d3502bd9dc374ff
parent31b5e9177f7c0ddcdb97e667f0634fdd13a8d59b (diff)
downloadgitea-bf48c8ebdd3975d1090115a9106069796c67a6da.tar.gz
gitea-bf48c8ebdd3975d1090115a9106069796c67a6da.zip
SQLite has a query timeout. Hopefully fixes most 'database locked' errors (#1961)
* SQLite has a query timeout. Fixes 'database locked' errors
-rw-r--r--conf/app.ini2
-rw-r--r--models/models.go4
2 files changed, 5 insertions, 1 deletions
diff --git a/conf/app.ini b/conf/app.ini
index 07164c2719..29f7015c07 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -166,6 +166,8 @@ PASSWD =
SSL_MODE = disable
; For "sqlite3" and "tidb", use absolute path when you start as service
PATH = data/gitea.db
+; For "sqlite3" only. Query timeout
+SQLITE_TIMEOUT = 500
[indexer]
ISSUE_INDEXER_PATH = indexers/issues.bleve
diff --git a/models/models.go b/models/models.go
index 02499b6eb6..02a782cde3 100644
--- a/models/models.go
+++ b/models/models.go
@@ -66,6 +66,7 @@ var (
// DbCfg holds the database settings
DbCfg struct {
Type, Host, Name, User, Passwd, Path, SSLMode string
+ Timeout int
}
// EnableSQLite3 use SQLite3
@@ -151,6 +152,7 @@ func LoadConfigs() {
}
DbCfg.SSLMode = sec.Key("SSL_MODE").String()
DbCfg.Path = sec.Key("PATH").MustString("data/gitea.db")
+ DbCfg.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
sec = setting.Cfg.Section("indexer")
setting.Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString("indexers/issues.bleve")
@@ -220,7 +222,7 @@ func getEngine() (*xorm.Engine, error) {
if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil {
return nil, fmt.Errorf("Failed to create directories: %v", err)
}
- connStr = "file:" + DbCfg.Path + "?cache=shared&mode=rwc"
+ connStr = fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d", DbCfg.Path, DbCfg.Timeout)
case "tidb":
if !EnableTiDB {
return nil, errors.New("this binary version does not build support for TiDB")