From 5fd07f7ab558b115664274fe1edb965e53abcf95 Mon Sep 17 00:00:00 2001 From: "Bora M. Alper" Date: Tue, 25 Dec 2018 18:34:19 +0300 Subject: [PATCH] fixed (v2) "unable to open database file" --- pkg/persistence/sqlite3.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/persistence/sqlite3.go b/pkg/persistence/sqlite3.go index 358b1fb..8b2b2d6 100644 --- a/pkg/persistence/sqlite3.go +++ b/pkg/persistence/sqlite3.go @@ -59,10 +59,11 @@ func makeSqlite3Database(url_ *url.URL) (Database, error) { // https://github.com/mattn/go-sqlite3/issues/618 // // Our solution is to set the connection max lifetime to infinity (reuse connection forever), and max open - // connections to 1. - db.conn.SetConnMaxLifetime(0) // https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime - db.conn.SetMaxOpenConns(1) - db.conn.SetMaxIdleConns(0) + // connections to 3 (1 causes deadlocks, unlimited is too lax!). Max idle conns are set to 3 to persist connections + // (instead of opening the database again and again). + db.conn.SetConnMaxLifetime(0) // https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime + db.conn.SetMaxOpenConns(3) + db.conn.SetMaxIdleConns(3) if err := db.setupDatabase(); err != nil { return nil, errors.Wrap(err, "setupDatabase")