SQLite: when connecting to an in-memory database, limit to 1 concurrent connection (#3255)

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
Alessandro (Ale) Segala 2023-12-06 12:41:35 -08:00 committed by GitHub
parent 8dfa4b663e
commit 87aea87e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

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