Skip to content

Commit

Permalink
SQLite: when connecting to an in-memory database, limit to 1 concurre…
Browse files Browse the repository at this point in the history
…nt connection (#3255)

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
  • Loading branch information
ItalyPaleAle committed Dec 6, 2023
1 parent 8dfa4b6 commit 87aea87
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions state/sqlite/sqlite_dbaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ func (a *sqliteDBAccess) Init(ctx context.Context, md state.Metadata) error {
return err
}

db, err := sql.Open("sqlite", connString)
a.db, err = sql.Open("sqlite", connString)
if err != nil {
return fmt.Errorf("failed to create connection: %w", err)
}

a.db = db
// If the database is in-memory, we can't have more than 1 open connection
if a.metadata.IsInMemoryDB() {
a.db.SetMaxOpenConns(1)
}

err = a.Ping(ctx)
if err != nil {
Expand Down

0 comments on commit 87aea87

Please sign in to comment.