From 329cb6fcdf234fb7c1977dcf44210ae3af557abe Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sun, 6 Mar 2022 11:52:40 +0100 Subject: [PATCH] set timeout pragma may fix #255 --- db/sqlite/sqlite.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/db/sqlite/sqlite.go b/db/sqlite/sqlite.go index 3bc08e7..604c410 100644 --- a/db/sqlite/sqlite.go +++ b/db/sqlite/sqlite.go @@ -164,7 +164,14 @@ func (db *Sqlite3Accessor) GetBlock(pos *coords.MapBlockCoords) (*db.Block, erro } func New(filename string) (*Sqlite3Accessor, error) { - db, err := sql.Open("sqlite", filename+"?mode=ro&_timeout=2000") + db, err := sql.Open("sqlite", filename+"?mode=ro") + if err != nil { + return nil, err + } + + // limit connection and set a busy-timeout to prevent errors if the db should be locked sometimes + db.SetMaxOpenConns(1) + _, err = db.Exec("pragma busy_timeout = 5000;") if err != nil { return nil, err }