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:
parent
8dfa4b663e
commit
87aea87e95
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue