Browse Source

Merge pull request #2212 from salmanisd/feature/use-only-one-sqlite3-conn

storage/sql: use only one sqlite3 connection
pull/2214/head
Maksim Nabokikh 5 years ago committed by GitHub
parent
commit
e650aef331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      storage/sql/sqlite.go

8
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 {

Loading…
Cancel
Save