From e1f3bfe41883a894318f9fbefb6479d9788b1c4e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 22 Jul 2021 13:48:39 +0200 Subject: [PATCH] storage/sql: use only one sqlite3 connection Signed-off-by: Salman Ahmed --- storage/sql/sqlite.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/storage/sql/sqlite.go b/storage/sql/sqlite.go index faefd89a..0994b190 100644 --- a/storage/sql/sqlite.go +++ b/storage/sql/sqlite.go @@ -32,12 +32,10 @@ func (s *SQLite3) open(logger log.Logger) (*conn, error) { if err != nil { return nil, err } - if s.File == ":memory:" { - // sqlite3 uses file locks to coordinate concurrent access. In memory - // doesn't support this, so limit the number of connections to 1. - db.SetMaxOpenConns(1) - } + // always allow only one connection to sqlite3, any other thread/go-routine + // attempting concurrent access will have to wait + db.SetMaxOpenConns(1) errCheck := func(err error) bool { sqlErr, ok := err.(sqlite3.Error) if !ok {